sulav.aryal
2007-06-11 22:32:42 UTC
class CopyBytes
{
public static void main(String args[])
{
FileInputStream infile=null;
FileOutputStream outfile=null;
byte byteRead;
try
{
infile=new FileInputStream("in.txt");
outfile=new FileOutputStream("out.txt");
do
{
byteRead=(byte)infile.read();
outfile.write(byteRead);
}
while(byteRead!=-1);
}
catch(FileNotFoundException e)
{
System.out.println(e);
}
catch(IOException e)
{
System.out.println(e);
}
finally
{
try
{
infile.close();
outfile.close();
}
catch(IOException e)
{}
}
}
}
/*//"error it says" it compile though:- java.io.FileNotFoundException:in.txt( The system cannot find the file specified)
Exception in thread "main" java.lang.NullPointerException at CopyBytes.main(CopyBytes.java:32) */