[Japi-cvs] SF.net SVN: japi:[750] tools
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-12-28 19:32:01
|
Revision: 750
http://japi.svn.sourceforge.net/japi/?rev=750&view=rev
Author: christianhujer
Date: 2008-12-28 19:31:55 +0000 (Sun, 28 Dec 2008)
Log Message:
-----------
Fixed several I/O issues.
Modified Paths:
--------------
historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java
historic/trunk/src/doc/guide/io/src/CatJAPI.java
historic/trunk/src/doc/guide/io/src/SortPlain.java
historic/trunk/src/doc/guide/io/src/UniqPlain.java
libs/argparser/trunk/src/doc/examples/Head.java
libs/argparser/trunk/src/doc/examples/Recode.java
libs/argparser/trunk/src/doc/examples/Tail.java
libs/argparser/trunk/src/doc/examples/Uniq.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/TokenReader.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/OututStreamConverter.java
libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestSer.java
progs/jtype/trunk/src/prj/net/sf/japi/jtype/Helper.java
progs/textedit/trunk/src/prj/net/sf/japi/progs/textedit/TextEditApplication.java
tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java
tools/cstyle/trunk/src/prj/net/sf/japi/cstyle/CStyle.java
tools/jgrep/trunk/src/prj/net/sf/japi/tools/jgrep/JGrep.java
tools/mail/trunk/src/prj/net/sf/japi/tools/mail/Mail.java
tools/mail/trunk/src/prj/net/sf/japi/tools/mail/PingPongSession.java
tools/replacer/trunk/src/prj/net/sf/japi/tools/replacer/Replacer.java
tools/scriptInterpreter/trunk/src/prj/net/sf/japi/tools/si/ScriptInterpreter.java
tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java
Modified: historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java 2008-12-28 16:16:40 UTC (rev 749)
+++ historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -126,7 +126,9 @@
private StringBuilder currentDirectiveArgs = new StringBuilder();
private Processor(final Reader inStream, final Writer outStream) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
in = inStream instanceof BufferedReader ? (BufferedReader) inStream : new BufferedReader(inStream);
+ //noinspection IOResourceOpenedButNotSafelyClosed
out = outStream instanceof PrintWriter ? (PrintWriter) outStream : new PrintWriter(outStream);
run();
out.flush();
@@ -205,6 +207,7 @@
}
public void process(final InputStream in, final OutputStream out) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
process(new InputStreamReader(in), new OutputStreamWriter(out));
}
Modified: historic/trunk/src/doc/guide/io/src/CatJAPI.java
===================================================================
--- historic/trunk/src/doc/guide/io/src/CatJAPI.java 2008-12-28 16:16:40 UTC (rev 749)
+++ historic/trunk/src/doc/guide/io/src/CatJAPI.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -13,6 +13,7 @@
* @throws IOException in case of I/O problems.
*/
public static void main(final String... args) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
copy(new ARGVInputStream(args), out);
}
Modified: historic/trunk/src/doc/guide/io/src/SortPlain.java
===================================================================
--- historic/trunk/src/doc/guide/io/src/SortPlain.java 2008-12-28 16:16:40 UTC (rev 749)
+++ historic/trunk/src/doc/guide/io/src/SortPlain.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -18,25 +18,29 @@
public static void main(final String... args) {
final List<String> lineList = new ArrayList<String>();
if (args.length == 0) {
- BufferedReader in = null;
try {
- in = new BufferedReader(new InputStreamReader(System.in));
- for (String line; (line = in.readLine()) != null; lineList.add(line));
+ final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ for (String line; (line = in.readLine()) != null; lineList.add(line));
+ } catch (final IOException e) {
+ System.err.println(e);
+ } finally {
+ in.close();
+ }
} catch (final IOException e) {
System.err.println(e);
- } finally {
- try { in.close(); } catch (final Exception ignore) { /* ignore */ }
}
} else {
for (final String arg : args) {
- BufferedReader in = null;
try {
- in = new BufferedReader(new FileReader(arg));
- for (String line; (line = in.readLine()) != null; lineList.add(line));
+ final BufferedReader in = new BufferedReader(new FileReader(arg));
+ try {
+ for (String line; (line = in.readLine()) != null; lineList.add(line));
+ } finally {
+ in.close();
+ }
} catch (final IOException e) {
System.err.println(e);
- } finally {
- try { in.close(); } catch (final Exception ignore) { /* ignore */ }
}
}
}
Modified: historic/trunk/src/doc/guide/io/src/UniqPlain.java
===================================================================
--- historic/trunk/src/doc/guide/io/src/UniqPlain.java 2008-12-28 16:16:40 UTC (rev 749)
+++ historic/trunk/src/doc/guide/io/src/UniqPlain.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -16,35 +16,37 @@
public static void main(final String... args) {
String prevLine = null;
if (args.length == 0) {
- BufferedReader in = null;
try {
- in = new BufferedReader(new InputStreamReader(System.in));
- for (String line; (line = in.readLine()) != null;) {
- if (!line.equals(prevLine)) {
- out.println(line);
+ final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ for (String line; (line = in.readLine()) != null;) {
+ if (!line.equals(prevLine)) {
+ out.println(line);
+ }
+ prevLine = line;
}
- prevLine = line;
+ } finally {
+ in.close();
}
} catch (final IOException e) {
err.println(e);
- } finally {
- try { in.close(); } catch (final Exception ignore) { /* ignore */ }
}
} else {
for (final String arg : args) {
- BufferedReader in = null;
try {
- in = new BufferedReader(new FileReader(arg));
- for (String line; (line = in.readLine()) != null;) {
- if (!line.equals(prevLine)) {
- out.println(line);
+ BufferedReader in = new BufferedReader(new FileReader(arg));
+ try {
+ for (String line; (line = in.readLine()) != null;) {
+ if (!line.equals(prevLine)) {
+ out.println(line);
+ }
+ prevLine = line;
}
- prevLine = line;
+ } finally {
+ in.close();
}
} catch (final IOException e) {
err.println(e);
- } finally {
- try { in.close(); } catch (final Exception ignore) { /* ignore */ }
}
}
}
Modified: libs/argparser/trunk/src/doc/examples/Head.java
===================================================================
--- libs/argparser/trunk/src/doc/examples/Head.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/doc/examples/Head.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -131,6 +131,7 @@
* @throws IOException in case of I/O errors.
*/
private void copyBytes(@NotNull final InputStream in) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final InputStream lin = in instanceof BufferedInputStream ? in : new BufferedInputStream(in);
final byte[] buf = new byte[numItems];
final int bytesRead = lin.read(buf, 0, numItems);
@@ -142,6 +143,7 @@
* @throws IOException in case of I/O errors.
*/
private void copyLines(@NotNull final InputStream in) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final BufferedReader lin = new BufferedReader(new InputStreamReader(in));
String line;
for (int i = 0; i < numItems && (line = lin.readLine()) != null; i++) {
Modified: libs/argparser/trunk/src/doc/examples/Recode.java
===================================================================
--- libs/argparser/trunk/src/doc/examples/Recode.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/doc/examples/Recode.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -128,7 +128,9 @@
* @throws IOException In case of I/O problems.
*/
public void recode(final InputStream in, final OutputStream out) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final Reader cin = new InputStreamReader(in, inputEncoding);
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final Writer cout = new OutputStreamWriter(out, outputEncoding);
final char[] buf = new char[BUF_SIZE];
//noinspection StatementWithEmptyBody
Modified: libs/argparser/trunk/src/doc/examples/Tail.java
===================================================================
--- libs/argparser/trunk/src/doc/examples/Tail.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/doc/examples/Tail.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -131,6 +131,7 @@
* @throws IOException in case of I/O errors.
*/
private void copyBytes(@NotNull final InputStream in) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final InputStream lin = in instanceof BufferedInputStream ? in : new BufferedInputStream(in);
final byte[] buf = new byte[numItems];
int bytesRead;
@@ -150,6 +151,7 @@
*/
private void copyLines(@NotNull final InputStream in) throws IOException {
final String[] buf = new String[numItems];
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final BufferedReader lin = new BufferedReader(new InputStreamReader(in));
int num = 0;
//noinspection StatementWithEmptyBody
Modified: libs/argparser/trunk/src/doc/examples/Uniq.java
===================================================================
--- libs/argparser/trunk/src/doc/examples/Uniq.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/doc/examples/Uniq.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -89,6 +89,7 @@
* @throws IOException In case of I/O problems.
*/
private void uniq(@NotNull final InputStream in) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
uniq(new InputStreamReader(in));
}
@@ -97,6 +98,7 @@
* @throws IOException In case of I/O problems.
*/
private void uniq(@NotNull final Reader in) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
final BufferedReader bin = in instanceof BufferedReader ? (BufferedReader) in : new BufferedReader(in);
String previousLine = bin.readLine();
if (previousLine != null) {
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -135,6 +135,7 @@
@NotNull public static List<String> readFromFile(@NotNull final File file) throws ArgumentFileNotFoundException {
final TokenReader in;
try {
+ //noinspection IOResourceOpenedButNotSafelyClosed
in = new TokenReader(new FileInputStream(file));
} catch (final FileNotFoundException e) {
throw new ArgumentFileNotFoundException(e);
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/TokenReader.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/TokenReader.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/TokenReader.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -52,6 +52,7 @@
* @param in InputStream to read from.
*/
public TokenReader(@NotNull final InputStream in) {
+ //noinspection IOResourceOpenedButNotSafelyClosed
this.in = new InputStreamReader(in);
next = readNextToken();
}
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/OututStreamConverter.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/OututStreamConverter.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/OututStreamConverter.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -42,6 +42,7 @@
}
/** {@inheritDoc} */
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
@NotNull public OutputStream convert(@NotNull final Locale locale, @NotNull final String arg) throws FileNotFoundException {
return "-".equals(arg) && !new File("-").exists() ? System.out : new FileOutputStream(arg);
}
Modified: libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java
===================================================================
--- libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java 2008-12-28 16:16:40 UTC (rev 749)
+++ libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -24,6 +24,7 @@
* @param in BufferedReader from which to return lines.
*/
public BRLineIterator(@NotNull final Reader in) {
+ //noinspection IOResourceOpenedButNotSafelyClosed
this.in = in instanceof BufferedReader ? (BufferedReader) in : new BufferedReader(in);
nextLine = readLine();
}
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestSer.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestSer.java 2008-12-28 16:16:40 UTC (rev 749)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestSer.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -26,7 +26,6 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.OutputStream;
import java.net.URL;
import net.sf.japi.progs.jeduca.jtest.QuestionCollection;
import net.sf.japi.progs.jeduca.swing.io.Exporter;
@@ -78,9 +77,10 @@
*/
private QuestionCollection load(final InputStream in) throws IOException {
try {
+ //noinspection IOResourceOpenedButNotSafelyClosed
return (QuestionCollection) (new ObjectInputStream(in).readObject());
- } catch (ClassNotFoundException e) {
- throw new IOException("This isn't a serialized JTest file");
+ } catch (final ClassNotFoundException e) {
+ throw new IOException("This isn't a serialized JTest file", e);
}
}
@@ -90,12 +90,11 @@
* @throws IOException in case of I/O-problems
*/
public void save(final QuestionCollection col, final File f) throws IOException {
- final OutputStream fout = new FileOutputStream(f);
+ final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(f));
try {
- final ObjectOutputStream out = new ObjectOutputStream(fout);
out.writeObject(col);
} finally {
- fout.close();
+ out.close();
}
}
Modified: progs/jtype/trunk/src/prj/net/sf/japi/jtype/Helper.java
===================================================================
--- progs/jtype/trunk/src/prj/net/sf/japi/jtype/Helper.java 2008-12-28 16:16:40 UTC (rev 749)
+++ progs/jtype/trunk/src/prj/net/sf/japi/jtype/Helper.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -80,6 +80,7 @@
try {
final Process process = runtime.exec(command);
final List<String> lines = new ArrayList<String>();
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
for (String line; (line = in.readLine()) != null; ) {
lines.add(line);
Modified: progs/textedit/trunk/src/prj/net/sf/japi/progs/textedit/TextEditApplication.java
===================================================================
--- progs/textedit/trunk/src/prj/net/sf/japi/progs/textedit/TextEditApplication.java 2008-12-28 16:16:40 UTC (rev 749)
+++ progs/textedit/trunk/src/prj/net/sf/japi/progs/textedit/TextEditApplication.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -37,10 +37,13 @@
@Override
public void save(@NotNull final Document<PlainDocument> doc, @NotNull final String uri) throws Exception {
final Writer out = new BufferedWriter(new OutputStreamWriter(openUriForwriting(uri)));
- final PlainDocument data = doc.getData();
- out.write(data.getText(0, data.getLength()));
- out.flush();
- out.close();
+ try {
+ final PlainDocument data = doc.getData();
+ out.write(data.getText(0, data.getLength()));
+ out.flush();
+ } finally {
+ out.close();
+ }
}
/** {@inheritDoc} */
Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java
===================================================================
--- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -112,10 +112,10 @@
*/
public static CharSequence readFile(final File file) throws IOException {
assert file.isFile();
+ final StringBuilder sb = new StringBuilder((int) file.length());
final BufferedReader in = new BufferedReader(new FileReader(file));
- final StringBuilder sb = new StringBuilder((int) file.length());
- final char[] buf = new char[BUF_SIZE];
try {
+ final char[] buf = new char[BUF_SIZE];
for (int charsRead; (charsRead = in.read(buf)) != -1; ) {
sb.append(buf, 0, charsRead);
}
Modified: tools/cstyle/trunk/src/prj/net/sf/japi/cstyle/CStyle.java
===================================================================
--- tools/cstyle/trunk/src/prj/net/sf/japi/cstyle/CStyle.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/cstyle/trunk/src/prj/net/sf/japi/cstyle/CStyle.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -108,6 +108,7 @@
* @throws IOException In case of I/O problems.
*/
public void check(@NotNull final InputStream stream) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final Reader in = new BufferedReader(new InputStreamReader(stream, encoding));
check(in);
}
Modified: tools/jgrep/trunk/src/prj/net/sf/japi/tools/jgrep/JGrep.java
===================================================================
--- tools/jgrep/trunk/src/prj/net/sf/japi/tools/jgrep/JGrep.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/jgrep/trunk/src/prj/net/sf/japi/tools/jgrep/JGrep.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -201,6 +201,7 @@
* @throws IOException in case of I/O problems.
*/
public void grep(@NotNull final InputStream in, @Nullable final String currentFile) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
grep(new InputStreamReader(in, encoding), currentFile);
}
@@ -210,6 +211,7 @@
* @throws IOException in case of I/O problems.
*/
public void grep(@NotNull final Reader reader, @Nullable final String currentFile) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final BufferedReader in = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
int lineNumber = 0;
for (String line; (line = in.readLine()) != null; ) {
Modified: tools/mail/trunk/src/prj/net/sf/japi/tools/mail/Mail.java
===================================================================
--- tools/mail/trunk/src/prj/net/sf/japi/tools/mail/Mail.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/mail/trunk/src/prj/net/sf/japi/tools/mail/Mail.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -68,6 +68,7 @@
}
session.sendAndWait("DATA", "354");
if (msg == null) {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
for (String line; (line = in.readLine()) != null && !".".equals(line);) {
session.send(line);
Modified: tools/mail/trunk/src/prj/net/sf/japi/tools/mail/PingPongSession.java
===================================================================
--- tools/mail/trunk/src/prj/net/sf/japi/tools/mail/PingPongSession.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/mail/trunk/src/prj/net/sf/japi/tools/mail/PingPongSession.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -68,6 +68,7 @@
* @throws IOException in case of I/O problems when connecting the streams of the socket.
*/
public PingPongSession(@NotNull final InputStream in, @NotNull final OutputStream out, @Nullable final Socket socket) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
this(new InputStreamReader(in, "ASCII"), new OutputStreamWriter(out, "ASCII"), socket);
}
@@ -77,7 +78,9 @@
* @param socket Socket to communicate with.
*/
public PingPongSession(@NotNull final Reader in, @NotNull final Writer out, @Nullable final Socket socket) {
+ //noinspection IOResourceOpenedButNotSafelyClosed
sin = in instanceof BufferedReader ? (BufferedReader) in : new BufferedReader(in);
+ //noinspection IOResourceOpenedButNotSafelyClosed
sout = new PrintWriter(out, true);
this.socket = socket;
}
Modified: tools/replacer/trunk/src/prj/net/sf/japi/tools/replacer/Replacer.java
===================================================================
--- tools/replacer/trunk/src/prj/net/sf/japi/tools/replacer/Replacer.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/replacer/trunk/src/prj/net/sf/japi/tools/replacer/Replacer.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -194,6 +194,7 @@
*/
@NotNull public CharSequence read(@NotNull final InputStream stream) throws IOException {
final StringBuilder sb = new StringBuilder();
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final Reader in = new InputStreamReader(stream instanceof BufferedInputStream ? stream : new BufferedInputStream(stream), encoding);
final char[] buf = new char[BUF_SIZE];
//noinspection NestedAssignment
Modified: tools/scriptInterpreter/trunk/src/prj/net/sf/japi/tools/si/ScriptInterpreter.java
===================================================================
--- tools/scriptInterpreter/trunk/src/prj/net/sf/japi/tools/si/ScriptInterpreter.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/scriptInterpreter/trunk/src/prj/net/sf/japi/tools/si/ScriptInterpreter.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -1,6 +1,7 @@
package net.sf.japi.tools.si;
import java.io.InputStreamReader;
+import java.io.IOException;
import java.util.List;
import java.util.TreeSet;
import java.util.Collection;
@@ -8,6 +9,7 @@
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.Option;
@@ -40,11 +42,16 @@
/** {@inheritDoc} */
@SuppressWarnings({"InstanceMethodNamingConvention"})
- public int run(@NotNull final List<String> args) throws Exception {
+ public int run(@NotNull final List<String> args) throws IOException, ScriptException {
final ScriptEngineManager sem = new ScriptEngineManager();
final ScriptEngine se = sem.getEngineByMimeType(mimeType);
se.getBindings(ScriptContext.ENGINE_SCOPE).put("cmd", this);
- se.eval(new InputStreamReader(System.in));
+ final InputStreamReader in = new InputStreamReader(System.in);
+ try {
+ se.eval(in);
+ } finally {
+ in.close();
+ }
return 0;
}
Modified: tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java
===================================================================
--- tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java 2008-12-28 16:16:40 UTC (rev 749)
+++ tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java 2008-12-28 19:31:55 UTC (rev 750)
@@ -59,6 +59,7 @@
* @throws IOException In case of I/O problems.
*/
public void scanForTodos(@NotNull final InputStream in) throws IOException {
+ //noinspection IOResourceOpenedButNotSafelyClosed
scanForTodos(new InputStreamReader(in, encoding));
}
@@ -67,6 +68,7 @@
* @throws IOException In case of I/O problems.
*/
public void scanForTodos(@NotNull final Reader cin) throws IOException {
+ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
final BufferedReader in = cin instanceof BufferedReader ? (BufferedReader) cin : new BufferedReader(cin);
int lineNumber = 0;
for (String line; (line = in.readLine()) != null; lineNumber++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|