Trade TXT file export

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.