• 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: Can't Use java.io.FileInputStream Within Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't Use java.io.FileInputStream Within Cocoa


  • Subject: Re: Can't Use java.io.FileInputStream Within Cocoa
  • From: François Frisch <email@hidden>
  • Date: Fri, 13 Jul 2001 18:32:11 -0700

Use NSBundle.mainBundle.pathForResourseNamed("input.txt");

I use FileInputStream in cocoa all the time without any problems.


> Hello,
>
> I have found a very peculiar bug when using the java.io.FileInputStream
> within a java cocoa app. I'm trying to read a text file line by line, so
> I have to use the java.io classes here (correct me if there is a Java
> compatible Cocoa API that I can use instead). This is the gist of the
> code for opening the file stream, pretty standard.
>
> File inputFile = new File("input.txt");
> FileInputStream in = new FileInputStream(inputFile);
>
> The text file input.txt is within the same folder as the application
> itself, so the path for inputFile is correct. However, when I build the
> project from PB, and run it by double-clicking its icon and start the
> file reading method, I get a "FileNotFoundException" saying it can't
> find "input.txt." I then remake the project so it is a pure java app,
> and the FileInputStream happily locates the file. To confuse matters
> even more I run original cocoa java project from within Project Builder,
> and again FileInputStream properly locates the input.txt file. Thinking
> that this is just a problem with my installation of OS X (10.0.4), I
> tried it on another computer and got the same results. I simply cannot
> get FileInputStream to work within a cocoa app when I start it by
> double-clicking the icon.
>
> Has anyone else had a similar experience using the java.io classes
> within a java cocoa app? Any work-arounds? I am a student programmer, so
> I really have no idea where to go from here. Thanks in advance,
>
> -Jonathan Sick
> _______________________________________________
> cocoa-dev mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Can't Use java.io.FileInputStream Within Cocoa (From: Orbital Media Design <email@hidden>)

  • Prev by Date: Can't Use java.io.FileInputStream Within Cocoa
  • Next by Date: CGDirectDisplay API
  • Previous by thread: Can't Use java.io.FileInputStream Within Cocoa
  • Next by thread: Re: Can't Use java.io.FileInputStream Within Cocoa
  • Index(es):
    • Date
    • Thread