Source Code : File concatenation

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

File concatenation

    

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class Cat {
  public static void concatenate(String fileName) {
    RandomAccessFile file = null;
    String line = null;

    try {
      file = new RandomAccessFile(fileName, "r");
      while ((line = file.readLine()) != null) {
        System.out.println(line);
      }
      return;
    } catch (FileNotFoundException fnf) {
      System.err.println("File: " + fileName + " not found.");
    } catch (Exception e) {
      System.err.println(e.toString());
    } finally {
      if (file != null) {
        try {
          file.close();
        } catch (IOException io) {
        }
      }
    }

  }

  public static void main(String[] args) {
    for (int i = 0; i < args.length; i++)
      Cat.concatenate(args[i]);
  }
}

           
         
    
    
    
  

Thank with us