
If you look at the API of the read(char[] buf) method of the InputStreamReader class, you will see that we get -1 if we reach the end the stream (or the end of the file in our case).
This I know.But the point I am trying to make here is even though the read doesnot happen completely why are we getting res=-1?(See,if i remove the chracters
D’MELLO ROAD,^TMUMBAI – from the UTF 8(Without BOM) file I am trying to upload then the data is being read properly by the InputStreamReader class but if I add this data the int being returned from the read method is -1. )
Another thing that I have noticed is ,if I put any character in UTF8 file which is having more than 1 byte value then only this res=-1 is coming.
The complete code goes like this:
The output of the code is-
1.res==-1 if i add all the above characters(total of 9 bytes).
2.res==7(8-1(additional byte)) if i add a 2 byte character in the file.
3.res==8 if i add only 1 byte chracters in the file.And the file is getting successfully uploaded.
The above code should not basically return false .This will happen only if SIZE_OF_FILETRAILER=res=8.
Please help.This is little urgent .