private void Writefyfiletotxt (list list, httpservletrequest request, String drxh, FileOutputStream fos, string currdate, I NT start, int end, list<p2ploanextinfo> extlist,list<p2pproductrate> pprlist) throws Apsexception {
try {
List<p2prepayinfo> eprilist =getconvertrepayinfolist(list, start, end);//go to the list of nth to § m data
Generate summary Information 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;
Generate detail information
000001|0105|622700182400007108x| Zheng Hong |1402.75|14569| fz201404220042|13950316334
000002|0105|622700189254026136x| Lili |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)); Detail sequence
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 ());//Content Wrap
Fos.flush ();//Read all write to file at this time
Detailinfo = null;
}
} catch (Exception e) {
E.printstacktrace ();
}
}
Get line break
Private String gettxtnewline() {
byte[] NewLine = new byte[2];
newline[0]=0x0d;
newline[1]=0x0a;
return new String (NewLine);
}
Serialization string
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= "+seqstr";
}
if (Seqstr.length () ==4) {
rslt= "xx" +SEQSTR;
}
if (Seqstr.length () ==5) {
rslt= "0" +SEQSTR;
}
if (Seqstr.length () ==6) {
rslt=seqstr;
}
}
catch (Exception e) {
e.printstacktrace ( );
}
return rslt;
}
Trade TXT file export