BufferedWriter & FileWriter write into a data file.

  BufferedWriter ftp = new BufferedWriter(new FileWriter(ftpFile));
  BufferedWriter feed = new BufferedWriter(new FileWriter(noteFile));
  
//                ftp.write("open “+ip);
//                ftp.newLine();
//                ftp.write("open www1.man.com");
//                ftp.write("open "+availableFTPHost); //
//                ftp.newLine();  //20040617
//                ftp.write("pap_put");
//                ftp.newLine();
//                ftp.write("pcteam");
//                ftp.newLine();

  ftp.write("option batch on");  												ftp.newLine();
  ftp.write("option confirm off");  										ftp.newLine();
  ftp.write("open sftp://"+ sFtpId +":"+ sFtpPassword + "@"+ sFTPAddress);  ftp.newLine();
  ftp.write("cd " + papPath);  													ftp.newLine();
  ftp.write("ls");  																		ftp.newLine();
  ftp.write("put " + availableReportPath + filename);  	ftp.newLine();
  ftp.write("put " + noteFile);  												ftp.newLine();
  ftp.write("ls");  																		ftp.newLine();
  ftp.write("bye");
  ftp.close();

 

分数 12 作者 马新娟 单位 山东理工大学 Now this is a solutions for reading a file that exists.Please fill in blank in the codes. import java.util.Scanner; import public class ReadModuleFile { public static void main(String [] args) { FileReader aFileReader = new FileReader("modules.txt"); Scanner in = new Scanner( ); String aLineFromFile; while( ) { aLineFromFile = ; System.out.println(aLineFromFile); } ; aFileReader.close(); } } 评测结果 部分正确 得分 6 分 分数 12 作者 马新娟 单位 山东理工大学 Delete an entry which is begin with “CS4092“from a file.Please fill in blanks. import ; import java.util.*; public class DeleteAModule { public static void main(String [] args) { String searchFor = "CS4092", aLineFromFile; String filename = "Modules.txt"; ArrayList < String > modules = new ArrayList (); File resultsFile = new File(filename); if (!resultsFile.exists()) System.out.println(filename + "does not exist"); else { Scanner inFile = new Scanner( ); while(inFile.hasNext()) { aLineFromFile = inFile.nextLine(); if ( ) modules.add(aLineFromFile); } inFile.close(); PrintWriter outFile = new PrintWriter(filename); for (int i = 0; i < modules.size(); i++) outFile.println( ); outFile.close(); } } } 评测结果 部分正确 得分 6 分 分数 17 作者 马新娟 单位 山东理工大学 • You have been requested to write a Java application program to determine the winner of a Battle of the Bands Competition. • A data file named bands.txt contains the list of bands who entered the competition and each line is of the following format: BandNumber, BandName e.g. 1,Status Quo • When a person sends a text to vote for a particular band, the number of the band he/she voted for is entered into a file named votes.txt. This file has only one entry per line i.e. BandNumber. • You are required to list the name of the winning band. You may assume that there is only one winner. The following is the so
06-21
public Boolean backupDataToSql(String filePath) { List<BizOrderProduct> dataList = baseMapper.selectList(null); try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); writer.write("-- 备份时间:" + new Date() + "\n"); writer.write("TRUNCATE TABLE biz_energy_statistics;\n"); for (BizOrderProduct data : dataList) { StringBuilder columns = new StringBuilder(); StringBuilder values = new StringBuilder(); Field[] fields = data.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); Object value = field.get(data); if (value != null) { // 简单处理字段名(驼峰转下划线) String columnName = toSnakeCase(field.getName()); if (columns.length() > 0) columns.append(", "); columns.append(columnName); if (values.length() > 0) values.append(", "); if (value instanceof String) { values.append("'").append(value).append("'"); } else if (value instanceof Date) { values.append("'").append(sdf.format(value)).append("'"); } else { values.append(value); } } } String sql = String.format("INSERT INTO biz_energy_statistics(%s) VALUES (%s);\n", columns, values); writer.write(sql); } System.out.println("SQL 数据已导出至: " + filePath); return true; } catch (Exception e) { e.printStackTrace(); return false; } }这个方法,我这样调用,可以吗iBizOrderProductService.backupDataToSql("D:\\backup\\energy_statistics.sql");
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值