使用Java创建CSV文件 [英] Creating csv file using java

查看:219
本文介绍了使用Java创建CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用Java创建一个csv文件.我有以下代码,但似乎无法正常工作.

I'm currently working on creating a csv file in Java. I have the below code but doesn't seem to work.

String newFileName = "Temp" + fileName;
File newFile = new File(newFileName);

我不知道该怎么办.我需要指定文件路径吗? 请帮忙.谢谢.

I don't know what else to do. Do I need to specify the file path? Please help. Thanks.

推荐答案

java.io.File 只是

文件和目录路径名的抽象表示.

An abstract representation of file and directory pathnames.

您必须使用 FileWriter / PrintWriter / BufferedWriter 在磁盘上创建实际的物理文件.

you have to use FileWriter/PrintWriter/BufferedWriter to create an actual physical file on the disk.

Sorta像这样:

String newFileName = "Temp" + fileName;
File newFile = new File(newFileName);
BufferedWriter writer = new BufferedWriter(new FileWriter(newFile));

这篇关于使用Java创建CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆