summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/net/LineInputStream.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2005-11-15 23:20:01 +0000
committerMark Wielaard <mark@gcc.gnu.org>2005-11-15 23:20:01 +0000
commit8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch)
treea5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/gnu/java/net/LineInputStream.java
parent02e549bfaaec38f68307e7f34e46ea57ea1809af (diff)
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. From-SVN: r107049
Diffstat (limited to 'libjava/classpath/gnu/java/net/LineInputStream.java')
-rw-r--r--libjava/classpath/gnu/java/net/LineInputStream.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/libjava/classpath/gnu/java/net/LineInputStream.java b/libjava/classpath/gnu/java/net/LineInputStream.java
index 5ca068618da..81a3c7d1fd4 100644
--- a/libjava/classpath/gnu/java/net/LineInputStream.java
+++ b/libjava/classpath/gnu/java/net/LineInputStream.java
@@ -1,5 +1,5 @@
/* LineInputStream.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.net;
+import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FilterInputStream;
import java.io.IOException;
@@ -91,7 +92,8 @@ public class LineInputStream
buf = new ByteArrayOutputStream();
this.encoding = encoding;
eof = false;
- blockReads = in.markSupported();
+ // If it is already buffered, additional buffering gains nothing.
+ blockReads = !(in instanceof BufferedInputStream) && in.markSupported();
}
/**
@@ -109,11 +111,12 @@ public class LineInputStream
if (blockReads)
{
// Use mark and reset to read chunks of bytes
- final int MIN_LENGTH = 1024;
+ final int MAX_LENGTH = 1024;
int len, pos;
-
+
len = in.available();
- len = (len < MIN_LENGTH) ? MIN_LENGTH : len;
+ if (len == 0 || len > MAX_LENGTH)
+ len = MAX_LENGTH;
byte[] b = new byte[len];
in.mark(len);
// Read into buffer b