Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Write to file, see updates as you go.

Thread view: 
JasonDamianUs - 02 Apr 2007 06:29 GMT
This should be a simple question, but I am not sure how to do it
without opening and closing the file every time.

I want to be able to write lines to a file in Java, and watch the
progress in my text editor as I go.

The only was I can see so far is the close and re-open after every
write. This of course must be resource intensive...

Help is appreciated.

Jason
jasonus@gmail.com
Andrew Thompson - 02 Apr 2007 06:42 GMT
>This should be a simple question, but I am not sure how to do it
>without opening and closing the file every time.
>
>I want to be able to write lines to a file in Java, and watch the
>progress in my text editor as I go.

This depends largely on your text editor.
For example, I will usually open Ant ouptut logs in
TextPad.  Whenever I 'flip to' TextPad and there is
more data, the app. will prompt me with WTE
'The file has been updated, do you want to
reload it?'

What OS are you running?  TP is available for
Windows, though I expect there are similar text
editors available for Mac & *nix.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Sanjay - 02 Apr 2007 16:15 GMT
>> This should be a simple question, but I am not sure how to do it
>> without opening and closing the file every time.
[quoted text clipped - 12 lines]
> Windows, though I expect there are similar text
> editors available for Mac & *nix.

Eclipse does that too. So does Quanta, kate or gedit on Linux.
Andrew Thompson - 02 Apr 2007 19:16 GMT
>>> This should be a simple question, but I am not sure how to do it
>>> without opening and closing the file every time.
..
(auto-updating text editor)

>> ...I expect there are similar text
>> editors available for Mac & *nix.
>
>Eclipse does that too. So does Quanta, kate or gedit on Linux.

(chuckle) Yes.. Perhaps I should have said
"almost anything that is not 'Notepad'", but I
did not want to make too many presumptions.  ;-)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

JussiJ - 03 Apr 2007 00:59 GMT
> This should be a simple question, but I am not sure how to do it
> without opening and closing the file every time.
>
> I want to be able to write lines to a file in Java, and watch the
> progress in my text editor as I go.

The Zeus editor will automatically reload any unchanged file each
time you activate the editor:

   http://www.zeusedit.com

By 'unchanged file' I mean any file loaded in the editor but
not modified. If the file has been modified the user is prompted
before the file is reloaded.

> The only was I can see so far is the close and re-open after every
> write. This of course must be resource intensive...

Another option would be run the Java app in Zeus as a tool or via
a macro script and have Zeus capture the output as the app runs:

   http://www.zeusedit.com/forum/viewtopic.php?t=74
   http://www.zeusedit.com/forum/viewtopic.php?t=536

Jussi Jumppanen
Author: Zeus for Windows IDE
NOTE: Zeus is shareware.
Gordon Beaton - 03 Apr 2007 06:29 GMT
> I want to be able to write lines to a file in Java, and watch the
> progress in my text editor as I go.

Emacs can "tail" a file - it can watch the file for changes and
automatically update the buffer as the file is written, keeping the
cursor at the bottom so you always see the latest changes.

Of course it's easier just to run "tail -f" in a shell.

/gordon

--


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.