FYI. As Dmitri astutely points out below, there should be a "finally" in the
try/catch block in promptForInput method. What actually happened is that I
accidentally sent a "working copy" of the source file rather than
the "official" copy I had meant to send (that's what I get for leaving multiple
copies lying around :-).
The copy you _should_ have gotten is laid out pretty much as he describes.
Basically, anywhere where I am storing IOException to a variable, it is
actually being thrown (plus the finally block he describes). Other than that,
and a few semantic changes to some code comments, the files are the same, so I
won't bother resending it.
Thanks to Dmitri for the catch!
----- Forwarded message from Dmitri Colebatch <[EMAIL PROTECTED]> -----
Date: Mon, 06 Aug 2001 11:43:05 +1000
From: Dmitri Colebatch <[EMAIL PROTECTED]>
Reply-To: Dmitri Colebatch <[EMAIL PROTECTED]>
Subject: Re: Command-Line Utility Attached - Feedback Requested
To: Christopher Cain <[EMAIL PROTECTED]>
Hi,
I'm guessing you're probably after feedback on how it would fit into the
tomcat archtecture, but I thought I'd offer this anyway. I changed the
promptForInput to this:
[snip]
try {
System.out.println();
System.out.println(promptMessage);
br = new BufferedReader(new InputStreamReader(System.in));
userInput = br.readLine();
// Perform basic validation
if (userInput.length() > MAX_INPUT_LENGTH)
throw new IOException("Input limit exceeded");
else if (isMalformed(userInput))
throw new IOException("Input contains an illegal
character");
return userInput;
} catch (IOException ioe) {
// nb. this will be chained into a feline specific exception
throw ioe;
}
finally {
// Restore stdout to its original stream
restoreStdOut(initialStdOut);
}
}
The way you had it you were missing the situation where an undeclared
throwable was thrown, you weren't restoring your stdout.
btw - love the naming (o:
cheesr
dim