FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   troubles with loadStream
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: troubles with loadStream  (Read 327 times)
flamingweasel

theflamingweasel
troubles with loadStream
« on: Sep 18th, 2003, 10:06pm »

I'm having a problem with the loadStream function. After cut-and-pasting the code from the reference entry, I'm getting an error telling me loadStream can throw the "java.io.IOException" exception, and I have to catch it. Here's my code, which is in setup():
 
  InputStream input = loadStream("2.data");    
  InputStreamReader isr = new InputStreamReader(input);  
  BufferedReader reader = new BufferedReader(isr);
  while ((line = reader.readLine()) != null) {
    //do stuff with line here
  }
 
I can't use loadStrings because of the size of my data set. Do I need to catch the exception or am I using the function incorrectly?
 
fry


WWW
Re: troubles with loadStream
« Reply #1 on: Sep 19th, 2003, 4:05am »

for any sort of java i/o stuff like this you'll need to put  
 
try {
 
at the beginning  
 
and  
 
} catch (IOException e) {
  println("problem while reading");  // you're descriptive error msg
  e.printStackTrace();
}
 
after all that. loadStrings insulates you from it, but the regular java i/o you'll have to catch the exception.
 
Pages: 1 

« Previous topic | Next topic »