We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › FileInputStream?
Page Index Toggle Pages: 1
FileInputStream??? (Read 568 times)
FileInputStream???
Jun 19th, 2009, 3:54am
 
Hi,
my problem is quite simple: i just can't figure out how to load a file in my data folder into a fileIntputStream object.

the code (located in the setup function):
Code:

String typoPath = dataPath("typo.ttf");
FileInputStream ttf = new FileInputStream(typoPath);


it returns a "FileNotFound exception" error.

the path seems to be valid (print(typoPath) returns the good path).
I tried with absolute path, it didn't work neither...

What am i missing?
Re: FileInputStream???
Reply #1 - Jun 19th, 2009, 4:10am
 
I think you mistakenly read the error.
If I paste your two lines in one of my projects, I get a "Unhandled exception type FileNotFoundException" error, which is quite different.

That means you must surround the creation of FileInputStream with a try / catch block, in case the file is not found, even if you are sure it is there.
Re: FileInputStream???
Reply #2 - Jun 19th, 2009, 4:40am
 
Well... indeed, it works now!
thanks a lot!
Page Index Toggle Pages: 1