Bookmark Topic Watch Topic
  • New Topic

Regarding Streams

 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Report post to moderator
HI everyone,
Inorder to read data from text file i used FileinputStream,and put the data into another text file by using FileOutputStream
My program is compiled fine..and during the running process it is throwing an Exception of java.io.FileNotFoundException:file1(the system can'nt find the file specified)...i dont know the reason...why it is coming like this???can anyone help??

My code is:
import java.io.*;
public class ReadTxt{
public static void main(String args[]) throws IOException{
FileInputStream fis=new FileInputStream("file1");
FileOutputStream fos=new FileOutputStream("file2");
int ch;
while((ch=fis.read())!=-1){
fos.write((char)ch);
}
fis.close();
fos.close();
}
}
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate of this. Closing.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!