Hello everyone,
Am I required to handle exceptions that is the try and catch block every time I use DataInputStream methods to access files? I use eclipse IDE and I have done input output program in java, but I have not included exception in my code, and they still work. Is it compulsory to use exception in java input output. Here is my code.
Code:
Public static void hand(String[] args) {
FileInputStream fl = new FileInputStream("data.dat");
DataInputStream stream = new DataInputStream(fl);
boolean end = false;
int val;
while (! end){
val = flow.readInt();
if (val! = -1)
{
System.out.print(worth);
}
else
{
= endtrue;
System.out.print("End of File");
fl.close();
}
}
}
}
Bookmarks