[英]How to Read/Write CSV file dynamically?
我必须动态创建一个csv文件,我是动态创建的.... help,请提供完整代码
public class CSV {
public static void main(String[]args) throws FileNotFoundException{
PrintWriter pw = new PrintWriter(new File("d:/test.csv"));
StringBuilder sb = new StringBuilder();
sb.append("id");
sb.append(',');
sb.append("Name");
sb.append(',');
sb.append('\n');
sb.append("1");
sb.append(',');
sb.append("Akash");
sb.append(',');
sb.append('\n');
pw.write(sb.toString());
pw.close();
}
}
我想您快完成了。 我创建了代码的运行版本,将其输出输出到stdout而不是文件:
PrintWriter pw = new PrintWriter(System.out);
尝试去了解您的问题,以取得不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.