file not found Error
Hi everybody
I am doing small program to read the content's of file from the local PC using URL class. I have written the following code but i am getting the error as "file not found".
can anybody help me to solve this problem. how to give the path of the file to URL class constructor to read the content's of file.
import java.io.*;
import java.net.*;
class connect
{
publicstaticvoid main(String a[ ])
throws Exception
{
try
{
System.out.println("111111111");
URL u=new URL("http://PC-name/d:/pandurang/key.txt");
System.out.println("22222222222222");
URLConnection uc=u.openConnection();
System.out.println("333333333333333");
InputStream input=uc.getInputStream();
System.out.println("4444444444444");
FileOutputStream op=new FileOutputStream("d:/abc.txt");
System.out.println("5555555555555");
int c;
while((c=input.read())!=-1)
{
System.out.print((char)c);
op.write((char)c);
}
}
catch(Exception e)
{
System.out.print("file not found");
}
}
}
Output:
111111111
22222222222222
333333333333333
file not found
Regards
Bunty

