I get the following log messages from this code, and I'm not sure why I am not getting the output in the string. Can someone advise if I am converting something incorrectly? len
has a value, so I know the InputStream is good. location
is also verified as good.
The files size I'm reading is 42.7 KB.
FileServices fs = new FileServices("");
InputStream in = fs.getInputStreamFromVault(location);
int len;
String strFileContents = "";
logger.info(logPrefix + "file1 ");
BufferedInputStream inBuff = new BufferedInputStream(in);
logger.info(logPrefix + "file2 ");
byte[] buf = new byte[564000];
logger.info(logPrefix + "file3 ");
int bytesRead = 0;
while ((len = inBuff.read(buf)) > 0) {
logger.info(logPrefix + "file4 ");
logger.info("len " + len);
strFileContents += new String(buf, 0, bytesRead);
logger.info("bytesRead " + bytesRead);
//String string = new String(buf, "UTF-8");
//stream.write(buf, 0, len);
logger.info("strFileContents " + strFileContents);
}
Log output
INFO : [prefix] file1
INFO : [prefix] file2
INFO : [prefix] file3
INFO : [prefix] file4
INFO : len 43681
INFO : bytesRead 0
INFO : strFileContents