交易Txt文件导出
private void writeFYFileToTxt(List list, HttpServletRequest request, String drxh, FileOutputStream fos, String currDate, int start, int end, List<P2pLoanExtInfo> extList,List<P2pProductRate> pprList) throws APSException {
? ?try {
?? ?List<P2pRepayInfo> ePriList = getConvertRepayInfoList(list, start, end);//去list中的第n到第m條數據
???
?? ?// 生成 匯總信息? 0002900F0230755|AC01|20150611|001A|425|1061199.91
??? StringBuilder collectInfo = new StringBuilder(ConstantsApplication.MERCHANT_NUMBER);
??? collectInfo.append("|").append(ConstantsApplication.AC_OPERATION_CODE).append("|").append(currDate);
??? collectInfo.append("|").append(drxh + "A").append("|").append(ePriList.size()).append("|").append(countFYTotalAmount(ePriList));
?? ?fos.write((collectInfo.toString() + getTxtNewLine()).getBytes());
??? fos.flush();
??? collectInfo = null;
??? // 生成明細信息
//000001|0105|622700182400007108X|鄭紅|1402.75|14569|FZ201404220042|13950316334
//000002|0105|622700189254026136X|李麗|2104.13|15175|FZ201404230043|18605935575
?? ?for (int i = 0; i < ePriList.size(); i++) {
???? P2pRepayInfo ePri = (P2pRepayInfo) ePriList.get(i);
???? StringBuilder detailInfo = new StringBuilder(StringOperator.getSeq(i + 1)); // 明細序列
???? detailInfo.append("|").append(ePri.getRepayOpenBankCode());
???? detailInfo.append("|").append(ePri.getRepayAccountNo()).append("|").append(ePri.getLoanName()).append("|");
???? detailInfo.append(ePri.getMonthRtnAmount()).append("|").append(ePri.getPriNumber()).append("|").append(ePri.getLoanContractNo()).append ("|").append(ePri.getLoanNamePhone());
???? fos.write((detailInfo.toString() + getTxtNewLine()).getBytes());//內容自動換行
???? fos.flush();//本次讀取全部寫入文件
???? detailInfo = null;
?? ?}
??} catch (Exception e) {
???e.printStackTrace();
??}
?}
?//獲得換行符
?private String getTxtNewLine() {
??byte[] newLine = new byte[2];
??newLine[0]=0x0d;
??newLine[1]=0x0a;
??return new String(newLine);
?}
//序列化字符串
public static String getSeq(int seq){
??String rslt="";
??try{
???String seqStr=String.valueOf(seq);
???if(seqStr.length()==1){
????rslt="00000"+seqStr;
???}
???if(seqStr.length()==2){
????rslt="0000"+seqStr;
???}
???if(seqStr.length()==3){
????rslt="000"+seqStr;
???}
???if(seqStr.length()==4){
????rslt="00"+seqStr;
???}
???if(seqStr.length()==5){
????rslt="0"+seqStr;
???}
???if(seqStr.length()==6){
????rslt=seqStr;
???}
??}
??catch(Exception e){
???e.printStackTrace();
??}
??return rslt;
?}
轉載于:https://www.cnblogs.com/Defry/p/4576886.html
總結
- 上一篇: sqlmap注入检测经验0x01
- 下一篇: 20 个强大的 Sublime Text