Read One File And Write Other File

In this Program we two file and we copy data of first.txt file in second.txt file using java code

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyData {

public static void main(String[] args) throws IOException {
String pathInput=”D:\a\first.txt”;
String pathOutput=”D:\a\second.txt”;
FileInputStream in=null;
FileOutputStream out=null;
try {
in=new FileInputStream(pathInput);
out=new FileOutputStream(pathOutput);
int c;
while ((c=in.read())!=-1) {
out.write(c);
}
} catch (Exception e) {
System.out.println(e);
}finally{
if (!(in==null)) {
in.close();
}
if (!(out==null)) {
out.close();
}

}
System.out.println(“Copy Data”);
}

}


Notice: compact(): Undefined variable: limits in /home/javaprof/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/javaprof/public_html/wp-includes/class-wp-comment-query.php on line 853

Leave a Reply

Your email address will not be published. Required fields are marked *

47 + = 56