java导出csv文件
程序员文章站
2022-05-26 19:14:02
...
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import au.com.bytecode.opencsv.CSVWriter;
public class CsvDemo {
public static void main(String[] args) throws IOException {
final String[] header = new String[]{"name", "sex", "age"};
final String[][] data = new String[][]{header, {"日日", "F", "22"}, {"Tom", "M", "25"}, {"Lily", "F", "19"}};
File tempFile = new File("./Output.csv");
CSVWriter writer = new CSVWriter(new FileWriter(tempFile));
for (int i = 0; i < data.length; i++) {
writer.writeNext(data[i]);
}
writer.close();
}
}
上一篇: windows 查看端口占用
下一篇: Windows查看端口占用