Hi..
I'm currently simulating some physics with a java program.
The results is printed to a file line by line.
The program takes several hours to run, so I would like to look at the
output as soon as it has been calculated.
Can I do something so that the files closes after each cycle in the
program, so that I'm able to read it?
/Peter
|
|
0
|
|
|
|
Reply
|
garfieldpbj (9)
|
5/4/2008 12:02:43 AM |
|
(-Peter-) schrieb:
> Hi..
>
> I'm currently simulating some physics with a java program.
>
> The results is printed to a file line by line.
>
> The program takes several hours to run, so I would like to look at the
> output as soon as it has been calculated.
>
> Can I do something so that the files closes after each cycle in the
> program, so that I'm able to read it?
>
> /Peter
you can open a file and read it while it is being written to..
What you probably want is calling flush()/force() on your
stream/FileChannel so anything still cached is written out so you
actually can see it with other programs.
|
|
0
|
|
|
|
Reply
|
fakemail9312 (192)
|
5/4/2008 12:09:18 AM
|
|
(-Peter-) wrote:
> I'm currently simulating some physics with a java program.
>
> The results is printed to a file line by line.
>
> The program takes several hours to run, so I would like to look at the
> output as soon as it has been calculated.
>
> Can I do something so that the files closes after each cycle in the
> program, so that I'm able to read it?
On some platform you may be able to read it using simply
by having your program call flush frequently and then
view the file the usual way.
If you need to do it portable I believe you would have to
close the file one file and open another file.
Arne
|
|
0
|
|
|
|
Reply
|
arne6 (9617)
|
5/4/2008 12:16:01 AM
|
|
On 4 Maj, 02:09, Christian <fakem...@xyz.de> wrote:
> (-Peter-) schrieb:
>
> > Hi..
>
> > I'm currently simulating some physics with a java program.
>
> > The results is printed to a file line by line.
>
> > The program takes several hours to run, so I would like to look at the
> > output as soon as it has been calculated.
>
> > Can I do something so that the files closes after each cycle in the
> > program, so that I'm able to read it?
>
> > /Peter
>
> you can open a file and read it while it is being written to..
> What you probably want is calling flush()/force() on your
> stream/FileChannel so anything still cached is written out so you
> actually can see it with other programs.
can you explain how to actually do this?
/peter
|
|
0
|
|
|
|
Reply
|
garfieldpbj (9)
|
5/4/2008 12:47:49 AM
|
|
Just when you are finished writing just close the file. But when you
go to write again use a Random access file to append the new data. Or
you could use one of those streams that I can't remember the name of
that acts like one stream but copies the data into two so you could
give it a FileOutputStream to your file and one to System.out so the
console would be an exact copy of your file. I prefer the second one.
|
|
0
|
|
|
|
Reply
|
chasepreuninger (165)
|
5/4/2008 3:27:26 AM
|
|
On Sat, 3 May 2008 17:02:43 -0700 (PDT), "(-Peter-)"
<garfieldpbj@gmail.com> wrote, quoted or indirectly quoted someone who
said :
>Can I do something so that the files closes after each cycle in the
>program, so that I'm able to read it?
you can use flush, but the file stays open. You could output to the
console.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
|
0
|
|
|
|
Reply
|
see_website (4863)
|
5/4/2008 6:27:39 AM
|
|
(-Peter-) wrote:
> Hi..
>
> I'm currently simulating some physics with a java program.
>
> The results is printed to a file line by line.
>
> The program takes several hours to run, so I would like to look at the
> output as soon as it has been calculated.
>
Can you not deal with this through your OS? Under linux try the "tail"
command. Don't know about Windows though, but you can download some unix
utilities that have been complied for windows e.g
http://www.tailforwin32.sourceforge.net
HTH
|
|
0
|
|
|
|
Reply
|
nospam21 (11323)
|
5/4/2008 6:39:50 AM
|
|
(-Peter-) wrote:
>> The results is printed to a file line by line.
>>
>> The program takes several hours to run, so I would like to look at the
>> output as soon as it has been calculated.
BTDTGTTS wrote:
> Can you not deal with this through your OS? Under linux try the "tail"
> command. Don't know about Windows though, but you can download some unix
> utilities that have been complied for windows e.g
> http://www.tailforwin32.sourceforge.net
Or better yet, Cygwin.
<http://www.cygwin.com/>
--
Lew
|
|
0
|
|
|
|
Reply
|
lew (2143)
|
5/4/2008 10:46:34 AM
|
|
Lew wrote:
> (-Peter-) wrote:
>>> The results is printed to a file line by line.
>>>
>>> The program takes several hours to run, so I would like to look at
>>> the output as soon as it has been calculated.
>
> BTDTGTTS wrote:
>> Can you not deal with this through your OS? Under linux try the
>> "tail" command. Don't know about Windows though, but you can
>> download some unix utilities that have been complied for windows
>> e.g
>> http://www.tailforwin32.sourceforge.net
>
> Or better yet, Cygwin.
> <http://www.cygwin.com/>
Or evn better, MKS.
http://www.mkssoftware.com/products/tk/ds_tkdev.asp
Though Cygwin has the advantage of being free.
|
|
0
|
|
|
|
Reply
|
mscottschilling (1976)
|
5/4/2008 3:33:10 PM
|
|
Mike Schilling wrote:
> Or evn better, MKS.
>
> Though Cygwin has the advantage of being free.
I never used an MKS product that I liked.
--
Lew
|
|
0
|
|
|
|
Reply
|
lew (2143)
|
5/4/2008 5:03:15 PM
|
|
(-Peter-) wrote:
> Hi..
>
> I'm currently simulating some physics with a java program.
>
> The results is printed to a file line by line.
>
> The program takes several hours to run, so I would like to look at the
> output as soon as it has been calculated.
>
> Can I do something so that the files closes after each cycle in the
> program, so that I'm able to read it?
>
> /Peter
Why don't you just display the output in a window as well as writing it
to the file? If there is too much data to look at on the screen or you
need to get another application on it, close the file at each stage and
make a working copy, you can have the program notify you when they are
ready. There is a lot of noise here for a really simple problem.
--
Knute Johnson
email s/nospam/linux/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
|
|
0
|
|
|
|
Reply
|
nospam8071 (917)
|
5/4/2008 5:42:50 PM
|
|
(-Peter-) schrieb:
> On 4 Maj, 02:09, Christian <fakem...@xyz.de> wrote:
>> (-Peter-) schrieb:
>>
>>> Hi..
>>> I'm currently simulating some physics with a java program.
>>> The results is printed to a file line by line.
>>> The program takes several hours to run, so I would like to look at the
>>> output as soon as it has been calculated.
>>> Can I do something so that the files closes after each cycle in the
>>> program, so that I'm able to read it?
>>> /Peter
>> you can open a file and read it while it is being written to..
>> What you probably want is calling flush()/force() on your
>> stream/FileChannel so anything still cached is written out so you
>> actually can see it with other programs.
>
> can you explain how to actually do this?
>
> /peter
if you for example have something like
BufferedOutputStream buf = new BufferedOutputstream(new
FileOutputStream(file)));
buf.write(foo);
buf.flush(); //flush so eventually cached bytes are written to the
underlying stream i.e. file
|
|
0
|
|
|
|
Reply
|
fakemail9312 (192)
|
5/4/2008 6:39:08 PM
|
|
>
> BufferedOutputStream buf = new BufferedOutputstream(new
> FileOutputStream(file)));
>
> buf.write(foo);
> buf.flush(); //flush so eventually cached bytes are written to the
> underlying stream i.e. file
OK - I'm going to bite & show my ignorance 'cos I haven't read the source,
but surely a BufferedOutputStream must eventually write to to the uderlying
stream when when the buffer is full. I know that then OS issues come into
play, but even the OS has to write at some point.
|
|
0
|
|
|
|
Reply
|
nospam21 (11323)
|
5/4/2008 9:51:09 PM
|
|
Mike Schilling wrote:
> Lew wrote:
>> (-Peter-) wrote:
>>>> The results is printed to a file line by line.
>>>>
>>>> The program takes several hours to run, so I would like to look at
>>>> the output as soon as it has been calculated.
>> BTDTGTTS wrote:
>>> Can you not deal with this through your OS? Under linux try the
>>> "tail" command. Don't know about Windows though, but you can
>>> download some unix utilities that have been complied for windows
>>> e.g
>>> http://www.tailforwin32.sourceforge.net
>> Or better yet, Cygwin.
>> <http://www.cygwin.com/>
>
> Or evn better, MKS.
> http://www.mkssoftware.com/products/tk/ds_tkdev.asp
>
> Though Cygwin has the advantage of being free.
Cygwin also has more stuff.
And all the cygwin stuff is the original stuff build
from the same source as on Linux.
Arne
|
|
0
|
|
|
|
Reply
|
arne6 (9617)
|
5/5/2008 2:02:19 AM
|
|
Lew wrote:
> Mike Schilling wrote:
>> Or evn better, MKS.
>>
>> Though Cygwin has the advantage of being free.
>
> I never used an MKS product that I liked.
I used to use the utilities (I think the package was called the MKS
toolkit) and found them much more stable and less buggy than the
Cygwin versions..
|
|
0
|
|
|
|
Reply
|
mscottschilling (1976)
|
5/5/2008 3:29:21 AM
|
|
Arne Vajh�j wrote:
> Mike Schilling wrote:
>> Lew wrote:
>>> (-Peter-) wrote:
>>>>> The results is printed to a file line by line.
>>>>>
>>>>> The program takes several hours to run, so I would like to look
>>>>> at
>>>>> the output as soon as it has been calculated.
>>> BTDTGTTS wrote:
>>>> Can you not deal with this through your OS? Under linux try the
>>>> "tail" command. Don't know about Windows though, but you can
>>>> download some unix utilities that have been complied for windows
>>>> e.g
>>>> http://www.tailforwin32.sourceforge.net
>>> Or better yet, Cygwin.
>>> <http://www.cygwin.com/>
>>
>> Or evn better, MKS.
>> http://www.mkssoftware.com/products/tk/ds_tkdev.asp
>>
>> Though Cygwin has the advantage of being free.
>
> Cygwin also has more stuff.
>
> And all the cygwin stuff is the original stuff build
> from the same source as on Linux.
Right, which means that Cygwin deals with Windows idiosyncracies (line
termination, drive letters, extensions like .bat and .exe, etc.) less
effectively than MKS does.
> Arne
|
|
0
|
|
|
|
Reply
|
mscottschilling (1976)
|
5/5/2008 3:31:33 AM
|
|
Mike Schilling wrote:
> Lew wrote:
>> Mike Schilling wrote:
>>> Or evn better, MKS.
>>>
>>> Though Cygwin has the advantage of being free.
>> I never used an MKS product that I liked.
>
> I used to use the utilities (I think the package was called the MKS
> toolkit) and found them much more stable and less buggy than the
> Cygwin versions..
I don't encounter bugs in the Cygwin utilities. They're compiled from the
same source as the Linux versions, so your claim is rather surprising in that
one doesn't hear about too many bugs in the Linux versions. I haven't
encountered bugs in the Cygwin utilities in all the years I've been using
them. Of course, I've only used a fraction of the utilities available.
--
Lew
|
|
0
|
|
|
|
Reply
|
lew (2143)
|
5/5/2008 11:11:10 AM
|
|
Mike Schilling wrote:
> Right, which means that Cygwin deals with Windows idiosyncracies (line
> termination, drive letters, extensions like .bat and .exe, etc.) less
> effectively than MKS does.
I don't know how effectively MKS utilities deal with those things, so I can't
speak to the comparison, but the Cygwin utilities don't have problems with
those things.
--
Lew
|
|
0
|
|
|
|
Reply
|
lew (2143)
|
5/5/2008 11:13:29 AM
|
|
"Lew" <lew@lewscanon.com> wrote in message
news:2NSdnebWvaZHdoPVnZ2dnUVZ_hudnZ2d@comcast.com...
> Mike Schilling wrote:
>> Right, which means that Cygwin deals with Windows idiosyncracies (line
>> termination, drive letters, extensions like .bat and .exe, etc.) less
>> effectively than MKS does.
>
> I don't know how effectively MKS utilities deal with those things, so I
> can't speak to the comparison, but the Cygwin utilities don't have
> problems with those things.
I recently installed Cygwin on a new PC, copied over my standard shell
scripts, started it up, and nothing worked. Cygwin insisted that they
contained illegal characters. What the .... Oh, right, Cygwin needs to be
configured to understand CR/LF terminators.
I have a number of scripts that find interesting files and pass their name
as arguments to different utility programs. So long as I stay within the
Cygwin world it all works great, but once I use non-Cygwin programs (gvim,
javac, perforce, etc.) I have to remember to use the cygpath utility to
convert /cygdrive/d//dir/foo.bar to d:\dir\foo.bar. That is, rather than
being able to simply
alias vi gvim
I need the following:
export SHELL=c:/cygwin/bin/tcsh
args=""
for arg in $*
do
arg=`cygpath -w $arg`
args="$args $arg"
done
C:/Program\ Files/Vim/vim70/gvim.exe $args
|
|
0
|
|
|
|
Reply
|
mscottschilling (1976)
|
5/5/2008 4:08:05 PM
|
|
BTDTGTTS schrieb:
>> BufferedOutputStream buf = new BufferedOutputstream(new
>> FileOutputStream(file)));
>>
>> buf.write(foo);
>> buf.flush(); //flush so eventually cached bytes are written to the
>> underlying stream i.e. file
>
> OK - I'm going to bite & show my ignorance 'cos I haven't read the source,
> but surely a BufferedOutputStream must eventually write to to the uderlying
> stream when when the buffer is full. I know that then OS issues come into
> play, but even the OS has to write at some point.
>
>
yes eventually it must.
Though if for example his prolgram only makes small outputs like one
line of text.. or say 100 bytes per hour..
then the stream might not write to disc for several hours.
The buffered stream will only write when its buffer is filled up.
Assume a buffersize of 512Byte that makes 6 hours.
Christian
Christian
|
|
0
|
|
|
|
Reply
|
fakemail9312 (192)
|
5/5/2008 6:16:48 PM
|
|
Christian wrote:
> BTDTGTTS schrieb:
>>> BufferedOutputStream buf = new BufferedOutputstream(new
>>> FileOutputStream(file)));
>>>
>>> buf.write(foo);
>>> buf.flush(); //flush so eventually cached bytes are written to the
>>> underlying stream i.e. file
>>
>> OK - I'm going to bite & show my ignorance 'cos I haven't read the
>> source, but surely a BufferedOutputStream must eventually write to to the
>> uderlying stream when when the buffer is full. I know that then OS issues
>> come into play, but even the OS has to write at some point.
>>
>>
> yes eventually it must.
> Though if for example his prolgram only makes small outputs like one
> line of text.. or say 100 bytes per hour..
> then the stream might not write to disc for several hours.
> The buffered stream will only write when its buffer is filled up.
> Assume a buffersize of 512Byte that makes 6 hours.
I take your point. As a follow up, is BufferedOutputStream.flush() a request
or an instruction? Or is it OS dependant?
|
|
0
|
|
|
|
Reply
|
nospam21 (11323)
|
5/5/2008 8:47:01 PM
|
|
BTDTGTTS wrote:
> Christian wrote:
>
>> BTDTGTTS schrieb:
>>>> BufferedOutputStream buf = new BufferedOutputstream(new
>>>> FileOutputStream(file)));
>>>>
>>>> buf.write(foo);
>>>> buf.flush(); //flush so eventually cached bytes are written to the
>>>> underlying stream i.e. file
>>> OK - I'm going to bite & show my ignorance 'cos I haven't read the
>>> source, but surely a BufferedOutputStream must eventually write to to the
>>> uderlying stream when when the buffer is full. I know that then OS issues
>>> come into play, but even the OS has to write at some point.
>>>
>>>
>> yes eventually it must.
>> Though if for example his prolgram only makes small outputs like one
>> line of text.. or say 100 bytes per hour..
>> then the stream might not write to disc for several hours.
>> The buffered stream will only write when its buffer is filled up.
>> Assume a buffersize of 512Byte that makes 6 hours.
>
> I take your point. As a follow up, is BufferedOutputStream.flush() a request
> or an instruction? Or is it OS dependant?
>
BufferedOuputStream.flush ensures that all data is flushed to the stream
which it wraps and flush is called in turn. If the underlying stream is
a FileOutputStream, then the data will reach the operating system and
the OS flush method called (if applicable). However this does not imply
that file metadata (length, modification time) is updated. Windows is an
operating system where flushing the data is not sufficient to update the
metadata. As a result applications which are 'watching' the file for any
change may not see any change at the earliest possible time. To force
the metadata to be updated without closing the file, use
FileChannel.force(true).
Mark Thornton
|
|
0
|
|
|
|
Reply
|
mark.p.thornton (29)
|
5/5/2008 8:50:09 PM
|
|
Mike Schilling wrote:
> Arne Vajh�j wrote:
>> Mike Schilling wrote:
>>> Lew wrote:
>>>> (-Peter-) wrote:
>>>>>> The results is printed to a file line by line.
>>>>>>
>>>>>> The program takes several hours to run, so I would like to look
>>>>>> at
>>>>>> the output as soon as it has been calculated.
>>>> BTDTGTTS wrote:
>>>>> Can you not deal with this through your OS? Under linux try the
>>>>> "tail" command. Don't know about Windows though, but you can
>>>>> download some unix utilities that have been complied for windows
>>>>> e.g
>>>>> http://www.tailforwin32.sourceforge.net
>>>> Or better yet, Cygwin.
>>>> <http://www.cygwin.com/>
>>> Or evn better, MKS.
>>> http://www.mkssoftware.com/products/tk/ds_tkdev.asp
>>>
>>> Though Cygwin has the advantage of being free.
>> Cygwin also has more stuff.
>>
>> And all the cygwin stuff is the original stuff build
>> from the same source as on Linux.
>
> Right, which means that Cygwin deals with Windows idiosyncracies (line
> termination, drive letters, extensions like .bat and .exe, etc.) less
> effectively than MKS does.
Which must mean that Cygwin is better for nix emulation but MKS
is better for win integration.
Arne
|
|
0
|
|
|
|
Reply
|
arne6 (9617)
|
5/5/2008 9:55:32 PM
|
|
Arne Vajh�j wrote:
> Mike Schilling wrote:
>> Arne Vajh�j wrote:
>>> Mike Schilling wrote:
>>>> Lew wrote:
>>>>> (-Peter-) wrote:
>>>>>>> The results is printed to a file line by line.
>>>>>>>
>>>>>>> The program takes several hours to run, so I would like to
>>>>>>> look
>>>>>>> at
>>>>>>> the output as soon as it has been calculated.
>>>>> BTDTGTTS wrote:
>>>>>> Can you not deal with this through your OS? Under linux try the
>>>>>> "tail" command. Don't know about Windows though, but you can
>>>>>> download some unix utilities that have been complied for
>>>>>> windows
>>>>>> e.g
>>>>>> http://www.tailforwin32.sourceforge.net
>>>>> Or better yet, Cygwin.
>>>>> <http://www.cygwin.com/>
>>>> Or evn better, MKS.
>>>> http://www.mkssoftware.com/products/tk/ds_tkdev.asp
>>>>
>>>> Though Cygwin has the advantage of being free.
>>> Cygwin also has more stuff.
>>>
>>> And all the cygwin stuff is the original stuff build
>>> from the same source as on Linux.
>>
>> Right, which means that Cygwin deals with Windows idiosyncracies
>> (line termination, drive letters, extensions like .bat and .exe,
>> etc.) less effectively than MKS does.
>
> Which must mean that Cygwin is better for nix emulation but MKS
> is better for win integration.
That's my impression, yes. Since what I want is a useful set of tools
for Windows development, MKS is the superior toolset. Though MKS is
pricey and Cygwin is, well, free.
|
|
0
|
|
|
|
Reply
|
mscottschilling (1976)
|
5/6/2008 2:58:07 AM
|
|
Mike Schilling wrote:
> That's my impression, yes. Since what I want is a useful set of tools
> for Windows development, MKS is the superior toolset. Though MKS is
> pricey and Cygwin is, well, free.
Don't forget a third option - the free but somewhat under-publicized
U/Win (http://en.wikipedia.org/wiki/UWIN). I haven't used it in years
but it worked very well when I last did, and I doubt it's gotten worse.
RM
|
|
0
|
|
|
|
Reply
|
rexm (52)
|
5/6/2008 11:19:16 AM
|
|
|
24 Replies
28 Views
(page loaded in 0.212 seconds)
|