CodePudding user response:
In my experience, is the JAVA to read a file, a JSP read the file has not been seen,
CodePudding user response:
Just started to learn, may say is less clear, is the best in the JSP to do a servlet to readCodePudding user response:
//read TXT file contentPublic static String txt2String () {
String filePath="D:/test. TXT";
The File File=new File (filePath);
The StringBuilder result=new StringBuilder ();
Try {
BufferedReader br=new BufferedReader (new FileReader (file));//construct a BufferedReader class to read the file
String s=null;
While ((s=br. ReadLine ())!=null) {//use the readLine method, a read a line of
Result. Append (System. LineSeparator () + s);
}
Br. The close ();
} the catch (Exception e) {
e.printStackTrace();
}
Return the result. The toString ();
}
In Java, first read TXT content stored in the database, and then display in the JSP page
CodePudding user response:
Serial number terminal number net sales net sales total cancel ticket total cancellation of terminal control state-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1, 4101030687101, 50, 474 normal 0 0
2, 4101030692101, 111, 836 0 0 normal
3, 4101030714101, 211, 3740 normal 0 0
This format is how?
CodePudding user response:
this TXT content format are fixed, you press line read, each line according to the space divisionCodePudding user response:
Finally found the split method is used to match the regular expression can be solved perfectly