import java.io.*;
class filedemo1
{
public static void main(String as[])
{
System.out.println("file related program");
int n;
try
{
FileInputStream fis=new FileInputStream("input.txt");
FileOutputStream fos=new FileOutputStream("newdata.txt");
int c;
while ((c = fis.read()) != -1) {
fos.write(c);
// System.out.print((char)c+""); display on screen
}
}
catch(FileNotFoundException e )
{
System.out.println("error for file");
}
catch(IOException e )
{
System.out.println("error for io");
}
}
}
Input file: input.txt
E:\sysem3>type input.txt
wel come to DBJ college
also to cs dept.
Output:
E:\sysem3>type output.txt
wel come to DBJ college
also to cs dept.
0 Comments
Post a Comment