commit
a8f7b306b7
@ -0,0 +1,29 @@
|
|||||||
|
package au.com.royalpay.payment.manage.valid;
|
||||||
|
|
||||||
|
import org.apache.commons.csv.CSVFormat;
|
||||||
|
import org.apache.commons.csv.CSVPrinter;
|
||||||
|
import org.apache.commons.csv.QuoteMode;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by davep at 2019-12-24 15:15
|
||||||
|
*/
|
||||||
|
public class CSVTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws IOException {
|
||||||
|
File file = File.createTempFile("csvtest",".csv");
|
||||||
|
FileWriter writer = new FileWriter(file);
|
||||||
|
CSVFormat format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withHeader("title", "标题1", "abc");//.withQuoteMode(QuoteMode.ALL_NON_NULL);
|
||||||
|
CSVPrinter printer = new CSVPrinter(writer, format);
|
||||||
|
printer.printRecord("test", "订单1234", "hello");
|
||||||
|
writer.flush();
|
||||||
|
System.out.println(file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue