i am not getting the desired output(the contents in a text file which i have saved in the jdk bin here is my code i got. Also what is return in the try catch block i wanna know.
it says file not found
import java.io.*;
class FileDemo
{
public static void main(String args[]) throws IOException
{
int i;
FileInputStream fin;
try
{
fin=new FileInputStream("nikhil.txt");
}
catch(FileNotFoundException e)
{
System.out.println("file not found");
return;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("no filename specified");
return;
}
do
{
i=fin.read();
if(i!=1)
System.out.print((char)i);
}
while(i!=-1);
fin.close();
}
}
i have created a text file nikhil stored in
C:\Program Files\Java\jdk1.6.0_02\bin