Home > Back-end >  For help, why write files when the first line is always one more limits
For help, why write files when the first line is always one more limits

Time:09-22

For help, why write files when the first row is always more than one line limits

Private int createFile () {


SimpleDateFormat querydate=new SimpleDateFormat (" yyyy - MM - dd ");

Calendar startDT=Calendar. GetInstance ();
StartDT. Add (Calendar DATE, 2);
String yesterday=querydate. The format (startDT getTime ());
CheckFileLine checkdata=https://bbs.csdn.net/topics/new CheckFileLine ();
Try {//database connection exception directly capture and release memory connection
The Connection cn=JDBCUtil. GetConnection ();

String SQL="select b.u serType, b.u serID, biggest ostType, s.T XNAMT, b.h eater_amt, to_char (b. inish_time, 'yyyymmddhh24miss') as ftime, supachai panitchpakdi aymentFlowNo" +
"From billinfo b, RECON_INFO s where s.R ECON_DATE='" + +" yesterday "and supachai panitchpakdi ROJECT_ID=' 213159721 'and s.B ILL_ID_THIRDSYS=b.B ILLID_THIRDSYS and s.R ECON_STATUS=' 02 'and s.S PLIT_STATUS=' 02 'and s.I S_PAYBACK=' 00 '";
Logger. The info (SQL);
PreparedStatement ps=cn. PrepareStatement (SQL);
The ResultSet rs=ps. ExecuteQuery ();
SimpleDateFormat namedate=new SimpleDateFormat (" yyyyMMddHH ");
Filename=namedate. The format (new Date ()) + ". TXT ".
FileUtil. FileLinesWrite (sc) getRealPath ("/") + "checkfile/" + filename," ");
int count=0;
While (rs), next ()) {
Checkdata. SetUserType (rs. Get string (" userType "));
Checkdata. SetUserID (rs. Get string (" userID "));
CostType checkdata. SetCostType (rs. Get string (" "));
//checkdata. SetCostPeroid (rs. Get string (" bill_date "));//is empty
Checkdata. SetPayAmount1 (rs. GetDouble (" TXNAMT "));
Checkdata. SetPayAmount2 (rs. GetDouble (" heater_amt "));
Ftime checkdata. SetPayDate (rs. Get string (" "));
PaymentFlowNo checkdata. SetSerialID (rs. Get string (" "). The substring (3, 23));
String aline=new String (checkdata. Pack (" GBK "), "GBK");
//String aline=new String (checkdata. Pack (ParamConfig. UTF_8), ParamConfig, UTF_8);

FileUtil. FileLinesWrite (sc) getRealPath ("/") + "checkfile/" + filename, aline);
count++;
}
SimpleDateFormat date2=new SimpleDateFormat (" yyyyMMdd ");
String datestr=date2. The format (startDT getTime ());
StartTime=datestr + "000000";
The endTime datestr +="235959";
return count;
} the catch (Exception e) {
e.printStackTrace();
}
return 0;
}

Public static String fileLinesWrite (String filePath, String content) {

String filedo="write";
FileWriter fw=null;

Try {
The File File=new File (filePath);
//if the folder does not exist, it is to create the folder
if (! File. GetParentFile (). The exists ()) {
file.getParentFile().mkdirs();
}
if(! File. The exists ()) {//if the file does not exist, then create a file, write the first line content
file.createNewFile();
Fw=new FileWriter (file);
Filedo="create".
} else {//if the file exists, then the additional content
Fw=new FileWriter (file, true);
}
} the catch (IOException e) {
e.printStackTrace();
}

PrintWriter pw=new PrintWriter (fw);
Pw. Println (content);
Pw. Flush ();

Try {
Fw. Flush ();
Pw. The close ();
Fw. Close ();
} the catch (IOException e) {
e.printStackTrace();
}

Return filedo;
}

CodePudding user response:

This is from the database file to write? What you decide to write the contents does it include a line break
  • Related