Java generate and download csv file -


i'm trying generate , download csv file in java project use old framework called echo studio 3, tomcat.

here code:

list<object> reportcount = this.getreport(accountid); arraylist<string[]> result = new arraylist<string[]>(); (object list: reportcount) {     string[] rowreport = (string[]) list;     result.add(new string[]{string.valueof(rowreport[0]),string.valueof(rowreport[1])}); }  file filename = new file("report.csv"); filewriter fw = new filewriter(filename); fw.append("name"); fw.append(','); fw.append("count"); fw.append('\n'); (string[] ls: result){     fw.append(ls[0].tostring());     fw.append(',');     fw.append(ls[1].tostring());     fw.append('\n'); } try {     fw.flush();     fw.close(); } catch (exception e) {     system.out.println("error while flushing/closing filewriter !!!");     e.printstacktrace(); } 

when code triggered, nothing happens, , have no error message. when run debug mode, result filled data, , breakpoint pass throw flush(), , no error, , client not getting generated file, did miss something?

you're writing file current working directory, may don't expect if you're running program in container tomcat.

given you've seen program execute calls, i'd test hypothesis changing file path absolute path, make sure code writing correctly. if does, it's path issue.

you add call find current working directory 1.


Comments