I wrote this code for read from a file and when page is load,it display in primefaces.But nothing shows in inputTextArea.
My Code:
@Named("GlassfishLogFileController")
@SessionScoped
public class PrintReport implements Serializable {
private static String logFile = null;
public String logFile() {
return logFile;
}
@PostConstruct
public void init() {
try {
logFile = readLogFile();
} catch (Exception e) {
}
}
public String readLogFile() throws FileNotFoundException, IOException {
BufferedReader br = null;
br = new BufferedReader(new FileReader("D:\\Report.log"));
//One way of reading the file
System.out.println("Reading the file using readLine() method:");
String contentLine = br.readLine();
while (contentLine != null) {
System.out.println(contentLine);
contentLine = br.readLine();
}
return contentLine;
}
}
xhtml:
<h:inputTextarea rows="30" cols="1000" value="#{GlassfishLogFileController.logFile}" />