Results 1 to 2 of 2
  1. #1
    mgrootsch is offline Member
    Join Date
    Sep 2008
    Posts
    4
    Rep Power
    0

    Default closing FileOutputStream?

    FileOutputStream fos = new FileOutputStream(new File(tempFilePath));
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    bos.write(bytesFitxer);
    bos.flush();
    bos.close();

    Should I close fos as well or is that not necessary?

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Just closing bos is enough, but you should do this in a finally block to be sure it happens.

Similar Threads

  1. FileOutputStream > int > FileInputStream
    By dudejonne in forum New To Java
    Replies: 11
    Last Post: 11-11-2009, 04:03 PM
  2. Replies: 6
    Last Post: 09-14-2009, 10:46 PM
  3. FileOutputStream gets NotSerializableException
    By xcallmejudasx in forum New To Java
    Replies: 0
    Last Post: 12-02-2008, 09:38 PM
  4. FileOutputStream question...
    By SCS17 in forum New To Java
    Replies: 2
    Last Post: 07-07-2008, 05:30 AM
  5. Closing packages
    By uncopywritable in forum New To Java
    Replies: 0
    Last Post: 08-13-2007, 11:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •