Name: paC48320 Date: 06/23/98
The available() method returns pos+super.available().
It should return (buf.length-pos)+super.available(), like e.g. BufferedInputStream.
import java.io.*;
public class PushbackInputStreamTest
extends PushbackInputStream
{
public static final String nullFilename
// SYSTEM DEPENDENCY. Choose one or the other
= "nul" // Windows, W95, NT, OS/2
// = "/dev/null" // Unix &c
;
public static void main(String[] args)
{
try
{
InputStream is = new PushbackInputStream(new FileInputStream(nullFilename));
int avail = is.available();
if (avail > 0)
System.out.println("FAIL: avail="+avail);
else
System.out.println("PASS: avail="+avail);
is.close();
}
catch (IOException ioe)
{
ioe.printStackTrace(System.err);
}
}
}
(Review ID: 28112)
======================================================================
- duplicates
-
JDK-4017414 java.io.PushbackInputStream.available() returns incorrect number
-
- Closed
-