1

I'm testing some code that reads data from a text file off of the internet using InputStreamReader. It worked the first time and returned the correct results; however, I've tried changing the contents of the file and even removing the file off of the server altogether, and the results returned always remain the same. I am also restarting the program fresh every time I check.

Then, I tried pointing the InputStreamReader to a different location by changing the URL object (to a nonexistent object), and finally, it did not find the file, as expected.

Does anyone know what could be causing this?

Here is the code:

    URL serverips = new URL("<URL redacted>");
    BufferedReader in = new BufferedReader(new InputStreamReader(
            serverips.openStream()));
    String ip = in.readLine();

    while (ip != null) {
        System.out.println("found server ip: " + ip);
        ip = in.readLine();
    }

Of course, I've also tried loading the URL via browser, and it behaves as expected (the displayed data changes when I change the contents of the hosted file).

  • If you changes URL and program still returns same result it seems impossible. Are you sure you that you run it correctly? Can jars or classes be cached? – Denis Borovikov Nov 13 '14 at 11:45
  • I had to wait a while before I saw the changes in my program. I'm guessing that the FTP host was doing some weird caching of my files. – user2060086 Oct 14 '15 at 23:04

0 Answers0