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)
======================================================================
- duplicates
-
JDK-4787132 (spec) FileInputStream.read(byte[] b, int off, int len) parameter "off" doc wrong
-
- Closed
-
-
JDK-6241817 Apply fix for 4150728 to JCE: (read(byte[],int,int)-spec of offset arg confusing
-
- Closed
-
- relates to
-
JDK-8154183 (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
-
- Closed
-