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

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.1.4, 1.4.0, 6
    • Fix Version/s: 6
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.6, solaris_8

      Description



      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: