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 › Reading files through Java's Scanner class
Page Index Toggle Pages: 1
Reading files through Java's Scanner class (Read 713 times)
Reading files through Java's Scanner class
Nov 17th, 2009, 12:21am
 
Hi,
I'm trying to read a text file from using the Java Scanner class, except no matter where I stick the text file Processing tells me it can't find it. It's kind of infuriating.

It should be in the same directory as the pde file referencing it, right? Or failing that, maybe in the data folder. I've tried everything I can think of, and I have no idea why it doesn't work. Help, please?
Re: Reading files through Java's Scanner class
Reply #1 - Nov 17th, 2009, 1:49am
 
If you use Java functions to access files, you must use the same magic as Processing to access files in data folder.
See the PApplet's developer's reference: you have the dataPath() and dataFile() functions to convert a file name to a full path to data folder.
Otherwise Java will use the current path, which seems to be in Processing's binary install folder.
Page Index Toggle Pages: 1