[英]How to Read/Write CSV file dynamically?
I have to create a csv file dynamically, i created it dynamically ....help please with full code 我必须动态创建一个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();
}
}
I think you're nearly done. 我想您快完成了。 I created a running variation of your code that does its output to stdout instead of a file:
我创建了代码的运行版本,将其输出输出到stdout而不是文件:
PrintWriter pw = new PrintWriter(System.out);
Try to get the difference as to understand your problem. 尝试去了解您的问题,以取得不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.