export data to txt file
2008-09-24 10:13
295 查看
response.reset();
response.setContentType("text/plain");
response.setHeader("Content-disposition", "attachment;filename="
+ fileName);
OutputStream out = null;
try {
out = response.getOutputStream();
BufferedWriter bufWriter = new BufferedWriter(
new OutputStreamWriter(out, "SJIS"));
//setCharacterEncoding(bufWriter,"SJIS");
if (campaignList != null && !campaignList.isEmpty()) {
DownloadTO dto = new DownloadTO();
bufWriter.write("");
for (Iterator iter = campaignList.iterator(); iter
.hasNext();) {
HashMap dataMap = (HashMap) iter.next();
StringBuffer sb = new StringBuffer();
sb.append("01");
sb.append(dto.getCurrentDate());
sb.append("GI899");
sb.append("08");
sb.append("001");
String customerCode = getValue(dataMap,
"ACCOUNT_NUMBER").toString();
sb.append(addZeroBefore(customerCode, 6)+ " ");
sb.append(fixLengthValue("", 5, " "));
sb.append(fixLengthValue("", 12, "0"));
Object accCashBack = getValue(dataMap,
"CASHBACK_AMOUNT");
String cashBackValue = truncateNumber(accCashBack);
sb.append(addZeroBefore(cashBackValue, 12));
sb.append(fixLengthValue("", 2, "9"));
//String cashBackDescr = "キヤツシユバツク";
String cashBackDescr = champaignName;
sb.append(fixLengthValue(cashBackDescr,25," ",false));
sb.append(fixLengthValue("", 1, " "));
sb.append(dto.getCurrentDate());
sb.append(fixLengthValue("", 2, "0"));
sb.append(fixLengthValue("", 8, " "));
sb.append(fixLengthValue("", 30, " "));
bufWriter.write(utf8ToShiftJis(sb.toString()));
bufWriter.write("/r/n");
}
}
bufWriter.flush();
bufWriter.close();
out.close();
} catch (IOException e) {
//throw exception
}
response.setContentType("text/plain");
response.setHeader("Content-disposition", "attachment;filename="
+ fileName);
OutputStream out = null;
try {
out = response.getOutputStream();
BufferedWriter bufWriter = new BufferedWriter(
new OutputStreamWriter(out, "SJIS"));
//setCharacterEncoding(bufWriter,"SJIS");
if (campaignList != null && !campaignList.isEmpty()) {
DownloadTO dto = new DownloadTO();
bufWriter.write("");
for (Iterator iter = campaignList.iterator(); iter
.hasNext();) {
HashMap dataMap = (HashMap) iter.next();
StringBuffer sb = new StringBuffer();
sb.append("01");
sb.append(dto.getCurrentDate());
sb.append("GI899");
sb.append("08");
sb.append("001");
String customerCode = getValue(dataMap,
"ACCOUNT_NUMBER").toString();
sb.append(addZeroBefore(customerCode, 6)+ " ");
sb.append(fixLengthValue("", 5, " "));
sb.append(fixLengthValue("", 12, "0"));
Object accCashBack = getValue(dataMap,
"CASHBACK_AMOUNT");
String cashBackValue = truncateNumber(accCashBack);
sb.append(addZeroBefore(cashBackValue, 12));
sb.append(fixLengthValue("", 2, "9"));
//String cashBackDescr = "キヤツシユバツク";
String cashBackDescr = champaignName;
sb.append(fixLengthValue(cashBackDescr,25," ",false));
sb.append(fixLengthValue("", 1, " "));
sb.append(dto.getCurrentDate());
sb.append(fixLengthValue("", 2, "0"));
sb.append(fixLengthValue("", 8, " "));
sb.append(fixLengthValue("", 30, " "));
bufWriter.write(utf8ToShiftJis(sb.toString()));
bufWriter.write("/r/n");
}
}
bufWriter.flush();
bufWriter.close();
out.close();
} catch (IOException e) {
//throw exception
}
相关文章推荐
- Export data out to file from sql server
- VBS Get Sql Server Table Data and Export to CSV File...
- Export DWG with ObjectData to ESRI shape file using AutoCAD Map 3D API
- export data to csv file
- VBS Get Sql Server Table Data and Export to CSV File...
- FileToData与DataToFile(优化版,txt为原始文件2倍大小)
- Unable to open stack trace file '/data/anr/traces.txt/: Permission denied
- Export large data from GridView to Excel file using C#
- export data to tsv file
- Export data to CSV file (two ways)
- Save Excel Data to Txt File With no quotes
- R转换.csv文件格式到.txt或.xlsx) [read.csv and export data to .txt or .xlsx]
- export data to xml file
- export data into .txt file
- How to export data as a CSV file in Symfony
- How To Validate A DataPump Export (EXPDP) Dump File ? (文档 ID 2113967.1) 转到底部 -------------------
- NetSuite SuiteScript 2.0 export data to Excel file(xls)
- Validate Data before Export via af:exportCollectionActionListener or af:fileDownloadActionListener
- mysql启动时提示 can't create/write to file 'D:\mysql\data\prn.pid'
- chmod data/cache/zfcache/file.txt 0666 failed