Beispiel: HTTP-Server auf HttpServlet-Basis

class InStream

import java.io.*;
import javax.servlet.ServletInputStream;

public class InStream extends ServletInputStream
{
 InputStream Stream;
 BufferedReader Reader;

 public InStream(InputStream in)
 {
  InputStream Stream = in;
  Reader = new BufferedReader(new InputStreamReader(in));
 }
 
 public int read() throws IOException
 { // abstrakte Methode von InputStream
  return Stream.read();
 }

 public int readLine(byte b[], int off, int len)
  throws IOException
 { // abstrakte Methode von ServletInputStream
  if (len <= 0)
      return 0;
  int c = read();
  if (c == -1)
      return -1;
  b[off] = (byte)c;
  int i = 1;
  for (; i < len ; i++)
  {
   c = read();
   if (c == -1)
    break;
   if (b != null)
   b[off + i] = (byte)c;
   if (c == '\n')
    break;
  }
  return i;
 }

// von Request benutzte Methoden
 public String readLine() throws IOException
 { return Reader.readLine(); }

 public boolean ready() throws IOException
 { return Reader.ready(); }
 
// Methode von InputStream
 public int available() throws IOException
 {
  return Stream.available();
 }

}