[Japi-cvs] SF.net SVN: japi:[1387] tools/archStat/trunk/src/prj/net/sf/japi/archstat/ ArchStat.java
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2009-10-05 00:29:47
|
Revision: 1387 http://japi.svn.sourceforge.net/japi/?rev=1387&view=rev Author: christianhujer Date: 2009-10-05 00:29:39 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Some code improvements. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:25:32 UTC (rev 1386) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:29:39 UTC (rev 1387) @@ -55,7 +55,7 @@ } /** The DocumentBuilder for parsing XML documents. */ - @NotNull private DocumentBuilder db; + @NotNull private DocumentBuilder documentBuilder; /** Whether or not to output memory statistics. */ private boolean memoryStatistics; @@ -74,7 +74,7 @@ System.err.println("Memory free (start): " + Runtime.getRuntime().freeMemory()); } final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - db = dbf.newDocumentBuilder(); + documentBuilder = dbf.newDocumentBuilder(); readDefaultCheckers(); final FileStat fileStat = new FileStat(checkers); for (final String arg : args) { @@ -137,7 +137,12 @@ */ public static CharSequence readFile(final File file) throws IOException { assert file.isFile(); - final StringBuilder sb = new StringBuilder((int) file.length()); + final long fileLength = file.length(); + if (fileLength > Integer.MAX_VALUE) { + throw new IOException("File too large" + file); + } + @SuppressWarnings({"NumericCastThatLosesPrecision"}) + final StringBuilder sb = new StringBuilder((int) fileLength); final BufferedReader in = new BufferedReader(new FileReader(file)); try { final char[] buf = new char[BUF_SIZE]; @@ -245,7 +250,7 @@ */ @Option({"c", "config"}) public void readCheckers(@NotNull final File file) throws SAXException, IOException { - readCheckers(db.parse(file)); + readCheckers(documentBuilder.parse(file)); } /** Reads additional configuration from the specified resource. @@ -254,7 +259,7 @@ * @throws SAXException in case of XML parsing errors. */ private void readCheckers(final URL url) throws SAXException, IOException { - readCheckers(db.parse(url.openStream())); + readCheckers(documentBuilder.parse(url.openStream())); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |