Loading...
Logo
Processing Forum
I'm trying to read a data file using the following:

Copy code
  1.         String filename = "/Users/myAccount/Processing/test_proj/data/lines.txt";
  2.         BufferedReader input = new BufferedReader(new FileReader(filename));

... but it's blowing up on new FileReader() with a FileNotFound exception.  This particular file is .java (not .pde), so AFAIK the dataPath() function isn't available.  

Any idea on the cause?  Or the cure?

Replies(2)

" AFAIK the dataPath() function isn't available"
Unless you have a PApplet instance at hand. Otherwise, it is just a Java question...

Are you sure it throws the exception? Or perhaps it doesn't even compile and tells you need to catch this exception... ("Unhandled exception type FileNotFounException").
See try / catch.
Bingo.  Yes, it was a compile time error telling me I needed a FileNotFound try/catch block.  (Forgive me, I'm just returning from a long vacation in Rubyland and my Java chops have atrophied.)

And I also just found this tutorial:


which explained how to pass a reference to PApplet in order to get access to all Processing goodness in pure Java objects.  That will go into the next rev.  (Perhaps there's a little tutorial to write about how to mix .pde and .java code, though I'm not volunteering until (a) I have my current deadline behind me and (b) I understand Processing a little bit better.)

Thanks!

- ff