Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #592

Re: Good practice or not to close the file before System.exit(1)?

Newsgroups comp.lang.java.help
Subject Re: Good practice or not to close the file before System.exit(1)?
References <87mxjjqmlf.fsf@merciadriluca-station.MERCIADRILUCA> <hbm3r615r2bk7bd2mu6i9sebgvnci1u5gs@4ax.com>
From Merciadri Luca <Luca.Merciadri@student.ulg.ac.be>
Organization ULg
Date 2011-04-22 23:20 +0200
Message-ID <8739la56fc.fsf@merciadriluca-station.MERCIADRILUCA> (permalink)

Show all headers | View raw


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roedy Green <see_website@mindprod.com.invalid> writes:

> On Fri, 22 Apr 2011 00:13:48 +0200, Merciadri Luca
> <Luca.Merciadri@student.ulg.ac.be> wrote, quoted or indirectly quoted
> someone who said :
>
>>In some cases, I need to make a System.exit(1) in my program. However,
>>a file has been opened some time before, and it has not been yet
>>closed. Do I need to close it for good practice? How is it handled by
>>Java if I don't close the file?
>
> This is not FORTRAN.  Java does not close files for you if you don't.
> If you were writing, the final buffers full would not get written. The
> OS of course would close the files at that level, but it knows nothing
> of the buffers.

4) I knew this, and I've now changed everything that had to be changed
regarding the files' closing, be it for input or output. However, I
was wondering... if you don't close a file opened for reading, what does it
actually change? The way UNIX deals with files fortunately never locks
a[n] (currently) opened file. I simply ask what kind of problems the
non-closing of an opened file for reading would cause.

(Consider here that I only speak about the UNIX case; I know that Java
is evidently platform independent; as a result, one might want to
depend only on the VM and not on the OS. I just want to be informed
about the kind of troubles it might cause, and how the non-closing is dealt.)
- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

First deserve, then desire.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2x8TcACgkQM0LLzLt8MhydiACfTU7tMHXSXY6lM+mIMj1CYn5O
AWgAoKrE6+kmAYDuahVkEbPiOiQ0LToS
=FEVU
-----END PGP SIGNATURE-----

Back to comp.lang.java.help | Previous | NextPrevious in thread | Find similar


Thread

Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 00:13 +0200
  Re: Good practice or not to close the file before System.exit(1)? rossum <rossum48@coldmail.com> - 2011-04-22 00:11 +0100
    Re: Good practice or not to close the file before System.exit(1)? rossum <rossum48@coldmail.com> - 2011-04-22 12:39 +0100
      Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 05:09 -0700
        Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-22 09:39 -0400
          Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 13:20 +0200
    Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 16:37 +0200
  Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 04:55 -0700
  Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 13:56 +0200
    Re: Good practice or not to close the file before System.exit(1)? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-04-22 09:36 -0300
    Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 08:20 -0700
      Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 09:04 -0700
        Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 15:24 -0700
          Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 18:11 -0700
            Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-23 08:25 -0700
      Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 18:55 +0200
        Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-22 13:40 -0400
        Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 10:55 -0700
          Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 22:58 +0200
            Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 23:09 +0200
              Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 14:30 -0700
                Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 15:38 -0700
                Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 17:00 -0700
                Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-22 22:10 -0400
                Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 19:46 -0700
                Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-23 09:54 -0400
  Re: Good practice or not to close the file before System.exit(1)? Roedy Green <see_website@mindprod.com.invalid> - 2011-04-22 12:45 -0700
    Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 23:20 +0200

csiph-web