Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Threaded View

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question offline explorer(how save images , css files ,js files?)

    Hello my dear friends.
    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?[Without the use of htmlparse class]
    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();
    Last edited by pbrockway2; December 27th, 2012 at 03:44 PM. Reason: code tags added


Similar Threads

  1. Replies: 3
    Last Post: August 3rd, 2012, 10:40 AM
  2. Replies: 2
    Last Post: February 24th, 2012, 07:56 PM
  3. [SOLVED] files size for files inside the JAR file
    By Natherul in forum Java Theory & Questions
    Replies: 3
    Last Post: February 9th, 2012, 03:17 PM
  4. Seraching through files in a folder for a pattern match inside the files.
    By dazzabiggs in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 2nd, 2011, 08:35 AM
  5. Replies: 1
    Last Post: March 22nd, 2011, 06:59 PM