cancel
Showing results for 
Search instead for 
Did you mean: 

File path in URL format?

Former Member
0 Kudos

Hi All,

I have uploaded file to the server in C:
temp folder.

Now I want to get the file path(c:\temp\test.doc) in URL format.

How do I get this?

Thanks

Sundar

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

use this kind of coding

URL url1 = new URL("http://localhost:8000/servapp/websites.html");

URLConnection ucon1 = url1.openConnection();

System.out.println(ucon1.getContentLength());

Object obj1 = ucon1.getContent();

System.out.println(obj1.getClass());

InputStream is = (InputStream)obj1;

byte b[] = new byte[10000];

int i = is.read(b,0,ucon1.getContentLength());

File f=new File("E:
htmlfiledown.html");

FileOutputStream fos=new FileOutputStream(f);

BufferedOutputStream bos=new BufferedOutputStream(fos);

int data;

for(int i1=0;i1<=ucon1.getContentLength()1024;i1+)

{

bos.write((char)b[i1]);

}

}catch(Exception e)

{

}

}

}

Former Member
0 Kudos

Hi,

Try thes steps.hope this will help u.

File doc = new File("x/y/z.doc");

doc.getURL();

Regards,

Lavanya

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

take a look at these,

File file = new File("text.txt");

String str = file.getAbsolutePath();

hope it helps

regards