简体   繁体   English

用java生成.csv并下载到本地

[英]Generate a .csv with java and download in local

I generate a .csv file in my class but I want this look like how when a user download the file with browser.我在班级中生成了一个 .csv 文件,但我希望这看起来像用户使用浏览器下载文件时的样子。 Currently the program download file in background scene and I need looks like a normal download, help?目前后台场景中的程序下载文件和我需要看起来像正常下载,帮助?

String archCSV = "C:\\"+nombre;
File file = new File(archCSV);

FileWriter fw = new FileWriter(file);
BufferedWriter writer = new BufferedWriter( fw );       

while (rs.next())
{
    befichero = new BEContenidofichero();
    befichero.setsContenido(rs.getString("Contenido"));

    writer.write(befichero.getsContenido());
    writer.write("\n");
}
writer.close();

我使用 servlet 来生成 CSV 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM