import java.io.*;

    class AppendArray                  // jdk 1.1.x and up
      { 
      public static void main (String args[]) 
        { 
        String s;
        byte[] ab;
        int iReadLength;
        ByteArrayInputStream bais;
        ByteArrayOutputStream baos;

        try
          {
          s = "abcdefghijklmnopqrstuvwxyz";
          bais = new ByteArrayInputStream (s.getBytes ());
          baos = new ByteArrayOutputStream ();
          ab = new byte[3];

          while ((iReadLength = bais.read (ab)) != -1)
            {
            baos.write (ab, 0, iReadLength);
            s = new String (baos.toByteArray ());
            System.out.println ("The output array is -->" + s + "<--");
            }
          }

        catch (Exception e)
          {
          System.out.println ("Exception: " + e);
          }
        } 
      } 

