是否有更简单的方法将CSV文件转换为SQL文件?:
BufferedReader input = new BufferedReader(new FileReader(new File("c:\\file.csv")));
Writer output = new BufferedWriter(new FileWriter(new File("c:\\file.sql")));
try {
String line = null;
String[] st = null;
while ((line = input.readLine()) != null) {
st = line.replace("\"","").split(",");
output.write("INSERT INTO `table` "
+ "(`column_id`, `column1`, `column2`) VALUES "
+ "(" + st[2] + ", " + st[0] + ", " + st[1] +")"
+ ";"
+ "COMMIT;\n");
}
} finally {
input.close();
output.close();
}