tag:blogger.com,1999:blog-4040559868205939473.post9071933392618455201..comments2024-03-27T13:22:28.965-07:00Comments on skillshared : How to read a dynamically growing file with Java?skillsharedhttp://www.blogger.com/profile/08794057725972720883noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4040559868205939473.post-77500185664720082402017-12-14T03:24:39.164-08:002017-12-14T03:24:39.164-08:00Refer This link :
https://web.archive.org/web/201...Refer This link :<br /><br />https://web.archive.org/web/20160510001134/http://www.informit.com/guides/content.aspx?g=java&seqNum=226Balaji Dongarenoreply@blogger.comtag:blogger.com,1999:blog-4040559868205939473.post-53421153511085358972016-02-12T01:12:16.801-08:002016-02-12T01:12:16.801-08:00import java.io.File;
import java.io.FileNotFou... import java.io.File;<br /> import java.io.FileNotFoundException;<br /> import java.io.IOException;<br /> import java.io.RandomAccessFile;<br /> import java.util.Timer;<br /> import java.util.TimerTask;<br /> public class ConsoleReader {<br /> public static void main(String[] args) {<br /> File file = new File("C:/Users/Binayak/Desktop/file1.txt");<br /> try {<br /> RandomAccessFile r = new RandomAccessFile(file, "rws");<br /> //First time read<br /> String str = null;<br /> while((str = r.readLine()) != null) {<br /> System.out.println("read"+str);<br /> }<br /> r.seek(r.getFilePointer());<br /> startTimer(r);<br /> } catch (FileNotFoundException e) {<br /> e.printStackTrace();<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> } <br /> }<br /> <br /> private static void startTimer(final RandomAccessFile r) {<br /> Timer timer = new Timer();<br /> timer.scheduleAtFixedRate(new TimerTask() {<br /> @Override<br /> public void run() {<br /> String str = null;<br /> try {<br /> while((str = r.readLine()) != null) {<br /> System.out.println(str);<br /> } <br /> r.seek(r.getFilePointer()); <br /> } catch (IOException e) { <br /> e.printStackTrace();<br /> }<br /> }<br /> }, 0, 500);<br /> }<br /> }<br /><br />this is random file access program..if i am adding anything new in that file it is reading that much data..but problem is it is reading after click on save button..i want to read that new data without clicking on save button ..please help..i am trying since from four daysAnonymoushttps://www.blogger.com/profile/08808750236495224889noreply@blogger.comtag:blogger.com,1999:blog-4040559868205939473.post-43717547937653962332016-02-12T01:02:56.455-08:002016-02-12T01:02:56.455-08:00import java.io.File;
import java.io.FileNotFou... import java.io.File;<br /> import java.io.FileNotFoundException;<br /> import java.io.IOException;<br /> import java.io.RandomAccessFile;<br /> import java.util.Timer;<br /> import java.util.TimerTask;<br /> public class ConsoleReader {<br /> public static void main(String[] args) {<br /> File file = new File("C:/Users/Binayak/Desktop/file1.txt");<br /> try {<br /> RandomAccessFile r = new RandomAccessFile(file, "rws");<br /> //First time read<br /> String str = null;<br /> while((str = r.readLine()) != null) {<br /> System.out.println("read"+str);<br /> }<br /> r.seek(r.getFilePointer());<br /> startTimer(r);<br /> } catch (FileNotFoundException e) {<br /> e.printStackTrace();<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> } <br /> }<br /> <br /> private static void startTimer(final RandomAccessFile r) {<br /> Timer timer = new Timer();<br /> timer.scheduleAtFixedRate(new TimerTask() {<br /> @Override<br /> public void run() {<br /> String str = null;<br /> try {<br /> while((str = r.readLine()) != null) {<br /> System.out.println(str);<br /> } <br /> r.seek(r.getFilePointer()); <br /> } catch (IOException e) { <br /> e.printStackTrace();<br /> }<br /> }<br /> }, 0, 500);<br /> }<br /> }<br /><br />this is random file access program..if i am adding anything new in that file it is reading that much data..but problem is it is reading after click on save button..i want to read that new data without clicking on save button ..please help..i am trying since from four daysAnonymoushttps://www.blogger.com/profile/08808750236495224889noreply@blogger.com