【发布时间】:2015-04-20 05:44:52
【问题描述】:
正在学习 Cassandra,并编写了一个可以从数据库读取文件的 restclient。
下面是我从数据库中检索数据的代码。
ResultSet rs = getFile(fileName);
Row row=rs.one();
ByteBuffer filecontent =row.getBytes("file_content");
byte[] data = new byte[filecontent.remaining()];
ByteBuffer bb = filecontent.get(data);
String filelocation = row.getString("file_location");
String filename = row.getString("filename");
ByteArrayInputStream filecontentfromDB= new ByteArrayInputStream(bb.array());
File file=writeToFile(filecontentfromDB,fileName);
if (rs == null) {
return null;
}
return file;
当我查看返回的文件时,我发现开头有一些垃圾字符,然后是我的文件内容。
请帮我删除垃圾数据
【问题讨论】: