Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Possible bug in Java 7

user8478974Nov 12 2011 — edited Jun 6 2012
If I run the following code in Java 6, there is no problem. If I run it in Java 7, the it hangs after reading and printing parts of the page.

I have posted a bug report, but the bug is closed because they are not able to reproduce the bug (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7045092).

I am wondering if anyone else gets a problem when running the code.

import java.io.*;
import java.net.URL;

public class HttpReaderBug {

    public static void main(String[] args) {
        try {
            URL url = new URL("http://en.wikipedia.org/wiki/Cancer");
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(url.openStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 4 2012
Added on Nov 12 2011
14 comments
2,848 views