• 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: Andre John Mas <email@hidden>
  • Date: Sat, 14 Jul 2001 10:11:08 -0400

First off, I would encourage people to use AWT for Java, as this allows for cross
platform Java apps and is very much in the spirit of the language ( imagine how
you would feel if someone was developing Java apps with an MS-Windows specific
API ). For OS X solutions Obj-C offers a number of advantages, notably in performance.

Beliefs aside, try displaying the value of File, I believe that there is a
method to get the absolute path of the the File. What I suspect is happening
is that the base path is the bundle itself or the JAR, not the folder in
which the bundle is located.

Andre


On Friday, July 13, 2001, at 09:14 PM, Orbital Media Design wrote:

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


--
mailto:email@hidden


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

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