First of all: the error you are facing:
JPEG StartOfImage, : FFD8
SOI.
, 1 + 2, , .
, :
byteToread =in.readInt();
bytesOut=new ByteArrayOutputStream();
bos = new BufferedOutputStream(bytesOut);
while (byteToread >cmpt) {
cmpt = in.read(dataEntre);
bos.write(dataEntre, 0, cmpt);
bos.flush();
byteToread-=cmpt;
}
, , , 100 .
- 100 50, 30, 20 .
:
iteration 1:
during while:
bytesToRead: 100
cmpt: 0
at the end of the loop:
bytesToRead: 50
cmpt: 50
iteration 2:
during while:
bytesToRead: 50
cmpt: 50
byteToRead (50) > cmpt (50), , 50 .
, , - :
bytesToread = in.readInt();
bytesOut=new ByteArrayOutputStream();
bos = new BufferedOutputStream(bytesOut);
while (byteToread > 0) {
cmpt = in.read(dataEntre);
bos.write(dataEntre, 0, cmpt);
bos.flush();
byteToread-=cmpt;
}
, ( , ). , . , , , . ( )
( )
byteToread=input.available();
, db, .
()
, InputStream , . , .
, , ( ), :
1: 1 (, 200 ).
2: (200)
3: 200 (, 150). (- )
4: 2 (, 300 )
5: (300)
6: N .
1: image1.length. 200.
2: 200 . 150 1, , 150 1, 2, 46 2.
, 1, 2 jpg. ( 46 image2 image2 afterall)
, , . , . .