Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4150728

(spec) {Data,}InputStream.read(byte[], int, int) - spec of offset argument confusing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.1.4, 1.4.0, 6
    • core-libs
    • beta
    • generic, x86, sparc
    • generic, solaris_2.6, solaris_8



      Name: paC48320 Date: 06/19/98


      // in DataInputStream Class
      // The defination for int off in
      // read(b[], off, len); in wrong
      // it shoulds be offset from where to store in the b[]
      // otherwise this program wont work.

      public class GetData{
      public GetData(){}

      public static void main(String[] args){
      byte[] b = new byte[256];
      int status = 0;
      try{
      URL link = new URL(args[0]);
      Object data = link.getContent();
      DataInputStream in = new DataInputStream(link.openStream());
      int start = 0, end = b.length -1;
      while(status != -1){
      status = in.read(b,5,end);
      System.out.println("Status :"+status+"\n"+new String(b));
      }

      }catch(Exception e){
      System.out.println(e.getMessage());
      }
      }
      }
      (Review ID: 29247)
      ======================================================================

            sjiang Shanliang Jiang (Inactive)
            pallenba Peter Allenbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: