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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -