Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Files not writing, closing files, finalize()

Reply
Thread Tools

Files not writing, closing files, finalize()

 
 
Arne Vajh°j
Guest
Posts: n/a
 
      11-19-2008
J. Davidson wrote:
> Joshua Cranmer wrote:
>> Note that this feature is actually relatively common in high-level
>> languages, buffering output data. Remember that something like disk
>> access is actually very expensive, so buffering is a tremendous boost
>> in speed.

>
> Anyone want to know why there's two layers of buffering in Java?
> It's not that Java doesn't trust the OS buffering. It's because each
> trip through JNI to call an OS API routine is expensive.
>
> So Java buffers because each JNI call is expensive. Then the OS buffers
> because each disk write is expensive.
>
> Another fifty years from now we'll probably have a big teetering tower
> of abstractions and I/O will get buffered at six or seven layers instead
> of just two.
>
> Wait, make that three. I think most modern disk controllers do some
> buffering of their own, because waiting for the right spot on a platter
> to rotate under the write head is expensive, and waiting for the head to
> move to a different cylinder is even more expensive.


There could already today potentially be:
- Java class buffer
- C RTL buffer
- OS IO buffer
- OS disk cache
- disk cache

Arne
 
Reply With Quote
 
 
 
 
Arne Vajh├Şj
Guest
Posts: n/a
 
      11-19-2008
Martin Gregorie wrote:
> Maybe so, but we need a lot more attention paid to using thick enough
> substrate material to minimize print-through for really permanent
> recordings. The other requirement would seem to be to archive at least
> one compatible tape drive plus paper copies of its specs and manual. So
> far nobody seems to have considered that aspect of long-term storage of
> material in formats that can't be read directly by humans.


That is a standard problem in archival context.

My understanding is that most places they drop the idea of keeping the
original media and simple copy to new media every X years - and
thereby always are on current media type.

Arne
 
Reply With Quote
 
 
 
 
Martin Gregorie
Guest
Posts: n/a
 
      11-19-2008
On Tue, 18 Nov 2008 21:57:12 -0500, Arne Vajh├Şj wrote:

> Martin Gregorie wrote:
>> Maybe so, but we need a lot more attention paid to using thick enough
>> substrate material to minimize print-through for really permanent
>> recordings. The other requirement would seem to be to archive at least
>> one compatible tape drive plus paper copies of its specs and manual. So
>> far nobody seems to have considered that aspect of long-term storage of
>> material in formats that can't be read directly by humans.

>
> That is a standard problem in archival context.
>
> My understanding is that most places they drop the idea of keeping the
> original media and simple copy to new media every X years - and thereby
> always are on current media type.
>

Sure. That's my usual approach. So far the only place I've almost caught
myself out is ss/sd and ds/dd floppies. As I still have a Flex9 box I can
read the disks if I need to: so far I haven't needed to. However, moving
the contents any place else would require soldering a board together
since that box doesn't have serial ports.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
 
Reply With Quote
 
John W Kennedy
Guest
Posts: n/a
 
      11-19-2008
Arne Vajh°j wrote:
> Roedy Green wrote:
>> On Sun, 16 Nov 2008 15:12:06 -0800 (PST), Matt <(E-Mail Removed)>
>> wrote, quoted or indirectly quoted someone who said :
>>
>>> Can somebody explain to me why file output doesn't work unless the
>>> file is closed explicitly?
>>>
>>> {
>>> PrintWriter pw = new PrintWriter(new File("test.txt"));
>>> pw.print("Hello world!");
>>> pw.close(); // necessary?
>>> }
>>>

>>
>> Looks ok. Try being more explicit where the file is written by
>> specifying drive and dir. Dump out the CWD, it may not be where you
>> expect. That it where test.txt will show up.

>
> Does that relate to the question asked ?


The question is awkwardly worded, and can easily be misread as "I can't
find the output file." (I still can't figure out why the original
questioner says the file "might" be truncated to zero bytes.)
--
John W. Kennedy
"Sweet, was Christ crucified to create this chat?"
-- Charles Williams. "Judgement at Chelmsford"
 
Reply With Quote
 
J. Davidson
Guest
Posts: n/a
 
      11-21-2008
Joshua Cranmer wrote:
> J. Davidson wrote:
>> Another fifty years from now we'll probably have a big teetering tower
>> of abstractions and I/O will get buffered at six or seven layers
>> instead of just two.

>
> So? There's already high-level API buffering, filesystem buffering, and
> probably disk-level buffering as well. As long as they can be reasonably
> guarded against concurrency issues, there's no problem.


Oh, I wasn't meaning to say there was a problem. Just that multiple
levels of buffering will become even more common, with even more levels,
and it will always be important to close the topmost level of stream in
the tower, rather than a lower down one. I've personally debugged Java
code with subtle bugs, like truncated output, caused by things like
closing an OutputStream that had a Writer attached instead of closing
the Writer, and I'm sure I'll be seeing more like that in the future.

On the other hand, too many layers of indirection is the one problem you
can't solve by adding a layer of indirection, or so I've heard.

- jenny
 
Reply With Quote
 
J. Davidson
Guest
Posts: n/a
 
      11-21-2008
Arne Vajh°j wrote:
> J. Davidson wrote:
>> Wait, make that three. I think most modern disk controllers do some
>> buffering of their own, because waiting for the right spot on a
>> platter to rotate under the write head is expensive, and waiting for
>> the head to move to a different cylinder is even more expensive.

>
> There could already today potentially be:
> - Java class buffer
> - C RTL buffer
> - OS IO buffer
> - OS disk cache
> - disk cache


See? Told ya.

- jenny
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PyGame, window is not closing, tut not helping globalrev Python 3 05-13-2008 01:26 AM
Closing popup window when closing parent window? =?Utf-8?B?Vk1J?= ASP .Net 3 02-15-2007 08:29 AM
Closing the doors 15 minutes before closing. doofus Computer Support 12 06-11-2005 08:20 AM
Closing Files E Tepp Java 1 02-02-2004 08:35 PM
Closing child window WITHOUT closing parent thomas Javascript 0 10-23-2003 04:10 PM



Advertisments