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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -