By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

FileInputStream and FileOutputStream

P: 5
import java.io.*;
class output
{
public static void main(String args[])throws Exception
{
try
{
FileInputStream fis=new FileInputStream("D:/R R/New Folder2/unit3/b.txt");
FileOutputStream fos=new FileOutputStream("D:/R R/New Folder2/unit3/a.txt");
int d;
while((d=fis.read())!=-1)
{
fos.write(d);
}
fis.close();
FileInputStream fis1=new FileInputStream("D:/R R/New Folder2/unit3/b.txt");
while((d=fis1.read())!=-1)
{
System.out.print((char)d);
}
fis1.close();
fos.close();
}
catch(FileNotFoundException e)
{
System.out.println(e);
}
}
}
hey any one can explain me this code
Feb 4 '12 #1
Share this Question
Share on Google+
2 Replies


P: 6
this program is used to write in a file but i dont know why file's name is different for output stream and input stream it should be same it is a.txt fot output stream and b.txt for input
is this program working fine ?
Feb 5 '12 #2

P: 5
program does not work fine . Nothing display's on cmd.
also i done using same file name for input stream and output stream
Feb 8 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.