ignores result of java.io.InputStream.read

846 단어 Inputstream
ignores result of java.io.InputStream.read(byte[], int, int)
 
This method ignores the return value of one of the variants of java.io.InputStream.read() which can return multiple bytes.  If the return value is not checked, the caller will not be able to correctly handle the case where fewer bytes were read than the caller requested.  This is a particularly insidious kind of bug, because in many programs, reads from input streams usually do read the full amount of data requested, causing the program to fail only sporadically.
 
해결 방법:if(inputStream!=null) {Byte Array OutputStream bytestream = new Byte Array OutputStream(), int ch, while((ch = inputStream.read()! = -1) {bytestream. write(ch);                }                but = bytestream.toByteArray();                bytestream.close();            }

좋은 웹페이지 즐겨찾기