When I run the following code, I get an error.
package practicing.io;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class JavaIO {
public static void main(String[] args) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream("xanaduout.txt");
out = new FileOutputStream("out.txt");
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}
This was taken right from Sun’s tutorial online. Please, tell me what’s wrong.
Does “xanaduout.txt” exist? In your current directory?
If not, you can always hard-code the path. But that’s not good practice 🙂
In any case, the error says exactly what’s happening: you’re trying to open a file … and the system can’t find it.