java - Read text file line by line in jsp -
I have a text file and I would like to read it line by line and display them separately, for example, text The first line of the file is 'Andy' and the second line is 'male', I want to show it in html:
Name: andy
Gender: Male
So far I can only get all the information, but I was unable to divide them. Can anyone help me solve it?
& lt;% string path = "few text / hotel 1.txt"; File file object = new file (path); Four data [] = new four [(int) fileObject.length ()]; FileReader filereader = new FileReader (path); Int charsread = filereader.read (data); Out.println (new string (data, 0, charset)); Filereader.close (); & Gt%;
You can use BufferedReader and read line per line
BufferedReader br = new BufferedReader (new FileReader (path)); String Line 1 = Faucet, Line 2 = Faucet; Line1 = br.readLine (); If (line1! = Zero) {line2 = br.readLine (); }
Comments
Post a Comment