Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7410673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:16:10+00:00 2026-05-29T06:16:10+00:00

This code is ment to download the source code of an html file but

  • 0

This code is ment to download the source code of an html file
but it skips some of the lines why would that happen?

import java.io.IOException;
import java.net.*;
import java.util.*;
import java.io.*;

public class downloadSource {
  private URL url;
  private URLConnection con;

  // Construct the object with a new URL Object resource
  downloadSource(String url) {
    try {
      this.url = new URL(url);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }
  }

  // Returns an object instance 
  public BufferedReader SourceCodeStream() throws IOException {
    return new BufferedReader(new InputStreamReader(this.url.openStream()));
  }


  public void returnSource() throws IOException, InterruptedException {
    // FIX ENTRIE SOURCE CODE IS NOT BEING DWLOADED

    // Instinate a new object by assigning it the returned object from
    // the invoked SourceCodeStream method.

    BufferedReader s = this.SourceCodeStream();     
    if(s.ready()) { 
      String sourceCodeLine = s.readLine();
      Vector<String> linesOfSource = new Vector();
      while(sourceCodeLine != null) {
        sourceCodeLine = s.readLine();
        linesOfSource.add(s.readLine());            
      }

      Iterator lin = linesOfSource.iterator();
      while(lin.hasNext()) {
      }
    }
  }         
}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:16:11+00:00Added an answer on May 29, 2026 at 6:16 am

    This reads two lines per iteration:

    while(sourceCodeLine != null) {
          sourceCodeLine = s.readLine();
    
          linesOfSource.add(s.readLine());
    
      }
    

    Should be:

    while(sourceCodeLine != null) {
          linesOfSource.add(sourceCodeLine);
          sourceCodeLine = s.readLine();
      }
    

    This second loop adds the first line to linesOfSource that was also skipped:

    String sourceCodeLine = s.readLine();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code i put it in the HTML page for check the file value,
this code was just working! but for some reason it stopped to work now.
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
I have html elements with class ajaxem that are ment to be used in
This code is reading from mysql db tables and should return few names. But
This code runs perfectly on Java but when I run this on Android platform,
This code works on Linux but fails to match on Windows: if ( preg_match
This code produces a POST request: urllib2.urlopen(http://somedomain.com/, data) I would like to produce a
This code works properly in my localhost. I am using xampp 1.7.3. but when
This code in the default login template: {{ form.errors }} Produces this html output

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.