3:37 pm - Friday September 21, 3488

File Program to Convert the abstract pathname into a file: URL

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

//Program to Convert the abstract pathname into a file: URL//

//Author : CandidJava//

//Description: Creates a URL from the specified <code>protocol</code> name, <code>host</code> name, and <code>file</code> name. The default port for the specified protocol is used.//

import java.io.*;

import java.net.*;

class tourl

{

public static void main(String args[]) throws Exception

{

File f1=new File("E:\5-jan\toStringDemo.txt");

//converts the specified filepath to absolute URL

URL url=f1.toURL();

File file=new File(url.getFile());

//prints the URL

System.out.println("URL:"+url);

System.out.println("File:"+file);

}}

 

OUTPUT:

D:candidjava /io/file> javac  tourl.java

D:candidjava /io/file> java ttourl

URL: File:/E:/5-jan/%-jan%09            oStringDemo.txt

File:E:\5-jan\-jan           oStringDemo.txt

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply