Jump to content
Sign in to follow this  
mohammad1992

offline explorer

Recommended Posts

i want to write a offline explorer program with java.i save url html code that user typed.(output.txt)now how to sava images and css files and java scripts file?Thanks.(output.txt seve in C:\Users\fh\Documents\NetBeansProjects\offline explorer\output.txt)

public static void main(String[] args) throws MalformedURLException, IOException {			String urlString;		  if (args.length == 1)			  urlString = args[0];		  else {			  System.out.println("Enter URL:");			  Scanner s = new Scanner(System.in);			  urlString = s.next();			  System.out.println("Using " + urlString);		  }		  URL u = new URL(urlString);		  URLConnection connection = u.openConnection();		  HttpURLConnection httpConnection = (HttpURLConnection) connection;		  int code = httpConnection.getResponseCode();		  String message = httpConnection.getResponseMessage();		  System.out.println(code + " " + message);		  if (code != HttpURLConnection.HTTP_OK)			  return; 		  InputStream instream = connection.getInputStream();		  Scanner in = new Scanner(instream);		  PrintWriter out = new PrintWriter("output.txt");		  while (in.hasNextLine())		  {			  String input = in.nextLine();			  out.println(input);			  System.out.println(input);		  }		  out.close();		

Edited by mohammad1992

Share this post


Link to post
Share on other sites

what's your problem? Are you getting any errors?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...