我尝试使用outputstream.write()在带有下载选项的文本文件中编写clob数据。但它只写第一行。我怎样才能写出完整的数据。这是我的代码:
OutputStream outputStream = response.getOutputStream();
oRs=oStmt.executeQuery("select subtxt from mybank.dt_subject where mailid = '"+sMailID+"' and sessionid = '"+sSessionID+"'");
while(oRs.next()){
outputResult = oRs.getString(1);
outputStream.write(outputResult.getBytes());
response.setContentType("text/plain");
response.setHeader("Content-disposition","attachment; filename=\"" +sFileName+".txt\"");
outputStream.flush();
outputStream.close();
}
答案 0 :(得分:0)
您正在第一次迭代( LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
convertViewHeader = inflater.inflate(R.layout.myflipperiew , null);
ViewFlipper flipper=(ViewFlipper)convertViewHeader.findViewById(R.id.myflipper);
mListView = (ListView) findViewById( R.id.mainListView );
mListView.addHeaderView(flipper);
)关闭流。
显然,在此之后你不能写过第一行。
答案 1 :(得分:0)
就像已经说过的那样 - 在while循环之后关闭你的outputStream:
OutputStream outputStream = response.getOutputStream();
oRs = oStmt.executeQuery("select subtxt from mybank.dt_subject where mailid = '" + sMailID + "' and sessionid = '" + sSessionID + "'");
while (oRs.next()) {
outputResult = oRs.getString(1);
outputStream.write(outputResult.getBytes());
response.setContentType("text/plain");
response.setHeader("Content-disposition", "attachment; filename=\"" + sFileName + ".txt\"");
}
outputStream.flush();
outputStream.close();