java - How can I address path of uploaded file to BufferedReader? -


excuse ignorance 'm new jsf , primeface. uploaded file primeface , ı need read that. can see codes , ask question.

send.java class

private uploadedfile file;  public uploadedfile getfile() {     return file; }  public void setfile(uploadedfile file) {     this.file = file; }  public void handlefileupload(fileuploadevent event) {     try {         file targetfolder = new file("c:\\users\\fatih\\desktop\\done pns\\pns_text");         inputstream inputstream =  event.getfile().getinputstream();         outputstream out = new fileoutputstream(new file(targetfolder,                 event.getfile().getfilename()));          int read = 0;         byte[] bytes = new byte[1024];          while ((read = inputstream.read(bytes)) != -1) {             out.write(bytes, 0, read);         }         inputstream.close();         out.flush();         out.close();     } catch (ioexception e) {         e.printstacktrace();     } } 

bufferedreaderpns.java class

  private bufferedreader br = null;   private string tokenstring = "";       //setters getters        public void read(){     try {          string scurrentline;          br = new bufferedreader(new filereader(??????????????));          while ((scurrentline = br.readline()) != null) {             system.out.println(scurrentline);             tokenstring  = tokenstring + scurrentline;         }      } catch (ioexception e) {         e.printstacktrace();     } {         try {             if (br != null)br.close();         } catch (ioexception ex) {             ex.printstacktrace();         }     }     } 

send.xhtml file

 <h:form enctype="multipart/form-data">  <p:fileupload mode="advanced" fileuploadlistener="#{send.handlefileupload}" allowtypes="/(\.|\/)(txt)$/" auto="true" /> <p:growl id="messages" showdetail="true"/>  </h:form>   <p:commandbutton  actionlistener="#{bufferedreaderpns.read}" action="send"  value="send" ajax="false" /> 

my problem don't know how can address file uploaded. in bufferedreaderpns.java class in read() method need write in question mark? wish can tell problem clearly, thank answers.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -