Public static void main (String [] args) {String format="insert into table_a (grp_num, number) values (' text ', '% s'); \ n "; The File dataFile=new File (" D:/test/data. TXT "); The File resultFile=new File (" D:/test/result. SQL "); Try (BufferedReader reader=new BufferedReader (new FileReader dataFile ()); BufferedWriter writer=new BufferedWriter (new FileWriter (resultFile))) {if (! ResultFile. The exists ()) {resultFile. CreateNewFile (); } String tempStr; While ((tempStr=reader. ReadLine ())!=null) {writer. Write (the String. Format (format, tempStr)); } writer. Flush (); } the catch (IOException e) {e.p rintStackTrace (); }
}
CodePudding user response: