summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--gnu/java/net/protocol/file/Connection.java19
2 files changed, 17 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index e9a7f74fb..6e7475bd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
2004-09-09 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/file/Connection.java
+ (lineSeparator): Made non-final.
+ (static): Removed.
+ (connect): Initialize lineSeparator lazily. Use ByteArrayInputStream
+ instead of StringBufferInputStream.
+
+2004-09-09 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/net/protocol/file/Connection.java
(connect): Handle file is a directory case.
2004-09-08 Sven de Marothy <sven@physto.se>
diff --git a/gnu/java/net/protocol/file/Connection.java b/gnu/java/net/protocol/file/Connection.java
index 89dd63a49..fe4db9e25 100644
--- a/gnu/java/net/protocol/file/Connection.java
+++ b/gnu/java/net/protocol/file/Connection.java
@@ -41,6 +41,7 @@ import gnu.java.security.action.GetPropertyAction;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -48,7 +49,6 @@ import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.StringBufferInputStream;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
@@ -74,14 +74,7 @@ public class Connection extends URLConnection
*/
private static final String DEFAULT_PERMISSION = "read";
- private static final String lineSeparator;
-
- static
- {
- GetPropertyAction getProperty = new GetPropertyAction("line.separator");
- lineSeparator = (String) AccessController.doPrivileged(getProperty);
-
- }
+ private static String lineSeparator;
/**
* This is a File object for this connection
@@ -137,13 +130,19 @@ public class Connection extends URLConnection
{
if (doInput)
{
+ if (lineSeparator == null)
+ {
+ GetPropertyAction getProperty = new GetPropertyAction("line.separator");
+ lineSeparator = (String) AccessController.doPrivileged(getProperty);
+ }
+
StringBuffer sb = new StringBuffer();
String[] files = file.list();
for (int index = 0; index < files.length; ++index)
sb.append(files[index]).append(lineSeparator);
- inputStream = new StringBufferInputStream(sb.toString());
+ inputStream = new ByteArrayInputStream(sb.toString().getBytes());
}
if (doOutput)