ClassLoader classLoader = CsvTest.class.getClassLoader();
File file = new File(classLoader.getResource("csv.csv").getFile());
OutputStream os = new FileOutputStream(file);
CsvWriter cw = new CsvWriter(os, ',', Charset.forName("utf-8"));
cw.write("hello world");
上面的代码运行后,文件还是空的,这是为什么?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用这种方法,项目编译后文件在classes文件夹下