67,513
社区成员
发帖
与我相关
我的任务
分享
protected String getContent(InputStream in) {
while (true) {
byte[] bufferMemory = new byte[2048];
int test = 0;
StringBuffer buffer = new StringBuffer();
try {
while ((test = in.read(bufferMemory)) != -1) {
buffer.append(new String(bufferMemory, 0, test));
if (buffer.indexOf("</root>") != -1) {
break;
}
}
return buffer.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
public void getTempDoc(String fileName, ConnectionContentDto contentDto) {
FileInputStream in = null;
try {
in = new FileInputStream(fileName);
Document doc = sreader.read(in);
contentDto.setTempDoc(doc);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}