[Schmitzm-commits] r835 - trunk/src/schmitzm/io
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat May 8 19:23:25 CEST 2010
Author: alfonx
Date: 2010-05-08 19:23:24 +0200 (Sat, 08 May 2010)
New Revision: 835
Modified:
trunk/src/schmitzm/io/IOUtil.java
Log:
Better newline handling in IOUtil.readURLasString(URL)
Modified: trunk/src/schmitzm/io/IOUtil.java
===================================================================
--- trunk/src/schmitzm/io/IOUtil.java 2010-05-06 20:18:21 UTC (rev 834)
+++ trunk/src/schmitzm/io/IOUtil.java 2010-05-08 17:23:24 UTC (rev 835)
@@ -54,7 +54,8 @@
private static Logger LOGGER = Logger.getLogger(IOUtil.class.getName());
/**
- * {@link FileFilter}, der alle Dateien akzeptiert, aber keine Verzeichnisse.
+ * {@link FileFilter}, der alle Dateien akzeptiert, aber keine
+ * Verzeichnisse.
*/
public static final FileFilter ALL_FILES_FILTER = createSimpleFileFilter(
"*", FilterMode.FILES_ONLY);
@@ -712,7 +713,8 @@
/**
* @return a {@link String} with the content of the {@link URL}. Do not use
- * this on long files! Returns <code>null</code> if an error occured.
+ * this on long files! Returns <code>null</code> if an error
+ * occured. A newline-character is added at every new line.
*/
public static String readURLasString(URL url) {
try {
@@ -726,11 +728,14 @@
BufferedReader inReader = new BufferedReader(inStream);
try {
String oneLine = inReader.readLine();
- if (oneLine == null) return "";
+ if (oneLine == null)
+ return "";
StringBuffer content = new StringBuffer();
while (oneLine != null) {
- content.append(oneLine+"\n");
+ content.append(oneLine);
oneLine = inReader.readLine();
+ if (oneLine != null)
+ content.append("\n");
}
return content.toString();
} finally {
@@ -749,7 +754,6 @@
return null;
}
-
/**
* Similar to {@link File#canWrite()}, but returns <code>true</code> if the
* file does not exist but can be created.
More information about the Schmitzm-commits
mailing list