• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading NSData from a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading NSData from a file


  • Subject: Re: Reading NSData from a file
  • From: Mike Schrag <email@hidden>
  • Date: Tue, 3 Apr 2007 11:55:29 -0400

    public static NSData nsDataFromFile( String filePath ) throws FileNotFoundException, IOException {
        File theFile = new File( filePath );
        return new NSData( new FileInputStream( theFile ), (int)theFile.length() );
    }
It doesn't appear that new NSData(InputStream, int) closes the stream ... Curiously, new NSData(file) DOES, but that's deprecated.

You may want to make this:

File theFile = new File(filePath);
FileInputStream theFileStream = new FileInputStream(theFile);
try {
return new NSData(theFileStream, (int)theFile.length());
}
finally {
theFileStream.close();
}

ms
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reading NSData from a file
      • From: Kieran Kelleher <email@hidden>
References: 
 >Reading NSData from a file (From: Janine Sisk <email@hidden>)
 >Re: Reading NSData from a file (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Fwd: WOWODC
  • Next by Date: Re: EditingContext/Sorting Problem SOLVED
  • Previous by thread: Re: Reading NSData from a file
  • Next by thread: Re: Reading NSData from a file
  • Index(es):
    • Date
    • Thread