public void createcsvfile() throws IOException, InterruptedException {
String text = data.get(dataKey);
System.out.println("input " + text);
String str[] = text.split(";");
String path = str[0];
String fileName = str[1];
BufferedWriter csvFileOutputStream = null;
File csvfile = new File(path, fileName);
if(!csvfile.exists()) {
csvfile.getParentFile().mkdirs();
try {
csvfile.createNewFile();
}catch(IOException e) {
e.printStackTrace();
}
}
try {
String csv = str[2];
csvFileOutputStream = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvfile), "UTF-8"), 1024);
System.out.println("csvFileOutputStream:" + csvFileOutputStream);
test.log(Status.INFO, "csvFileOutputStream:" + csvFileOutputStream);
// FileOutputStream in = new FileOutputStream(path);
try {
csvFileOutputStream.write(csv, 0, csv.length());
csvFileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
test.log(Status.INFO, "can't write");
}
} catch (FileNotFoundException e) {
e.printStackTrace();
test.log(Status.INFO, "can't find file");
}
test.log(Status.INFO, "edit csv file content");
}
在指定路径创建CSV文件
于 2019-11-06 12:06:08 首次发布