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_
   Suggestions
   Website, Reference, Example Suggestions
(Moderator: REAS)
   exception handling for loadStream(), etc.
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: exception handling for loadStream(), etc.  (Read 653 times)
kevinP

Email
exception handling for loadStream(), etc.
« on: Feb 16th, 2004, 8:39am »

Hi,
 
I see that I had the same problem as someone in December. Because the reference page for loadStream() doesn't mention it, I was under the impression that Processing took care of exception handling for input (see example code given there).
 
I think you should instead use something like this as an example:
Code:

try {
    InputStream input = loadStream(file);
    InputStreamReader isr = new InputStreamReader(input);
    BufferedReader reader = new BufferedReader(isr);
 
    String line;
    while ((line = reader.readLine()) != null) {
        println("next line is: " + line);
    }
} catch(Exception e) {
    println("error reading stream: "+e.getMessage());
}

 
(I tried adding the exception handling myself, but I hadn't realized that all these statements can/should be placed into one try block.)
 
After you see this once, it's quite easy.
 
-K
« Last Edit: Feb 16th, 2004, 8:39am by kevinP »  

Kevin Pfeiffer
Pages: 1 

« Previous topic | Next topic »