java - Csv file is empty when I writing content -
i trying write csv file. after execution of code bellow csv file still empty. file in folder .../webapp/resources/.
this dao class:
public class userdaoimpl implements userdao { private resource cvsfile; public void setcvsfile(resource cvsfile) { this.cvsfile = cvsfile; } @override public void createuser(user user) { string userpropertiesasstring = user.getid() + "," + user.getname() + "," + user.getsurname() +"\n";; system.out.println(cvsfile.getfilename()); filewriter outputstream = null; try { outputstream = new filewriter(cvsfile.getfile()); outputstream.append(userpropertiesasstring); } catch (ioexception e) { e.printstacktrace(); } { try { outputstream.close(); } catch (ioexception e) { e.printstacktrace(); } } } @override public list<user> getall() { return null; } } this part of beans.xml.
<bean id="userdao" class="pl.project.dao.userdaoimpl" p:cvsfile="/resources/users.cvs"/> program compiles , doesn't throw exceptions csv file empty.
if you're running app in ide, /webapp/resources used running app differ /webapp/resources in ide. try log full path file , check there.
Comments
Post a Comment