Hello, I use this code to read a textfile from my server:
String nextLine; URL url = null; URLConnection urlConn = null; InputStreamReader inStream = null; BufferedReader buff = null; try{ url = new URL("mytextfile.txt" ); urlConn = url.openConnection(); inStream = new InputStreamReader( urlConn.getInputStream()); buff= new BufferedReader(inStream); while (true){ nextLine =buff.readLine(); if (nextLine !=null){ System.out.println(nextLine); } else{ break; } } } catch(MalformedURLException e){ System.out.println("Please check the URL:" + e.toString() ); } catch(IOException e1){ System.out.println("Can't read from the Internet: "+ e1.toString() ); } }
I call this every 10 seconds to read the text file. The used memory is increased then every minute, and after 2/3 hours the service gets killed. I'am not sure why the memory is increased every minute. I'am not storing the string or appending it to something.
I need to read every 10 seconds my text file and it would be very nice if there is a solution.
Thanks