0

Hey peeps, im working on a method to format inputed text to include html, and i need to read line by line. is there any way i can do this? My java code looked like this:

public String convert(){
        int b=0;
        int e=0;               //vars
        String f = ""; 
        String p = poem.getText();
        if(poem.getLineCount()>1){
        for(int i=0;i<poem.getLineCount()-1;i++){ 
          try{  
              b=poem.getLineStartOffset(i); //gets start of line
              e=poem.getLineEndOffset(i); //gets end of line
          }catch(Exception E){
              System.out.println(E);
          }
          f+=p.substring(b,e-1)+"<br />"+"\n"; //add line break to end of line
        }
        } else{        
          f+=p+"\n"; //does this if 1 line
        }
        return f; //returns poem with line breaks
        
    }

Thanks!
M

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by vishesh
0

First of all Java and JavaScript is totally different thing. Java is OOp programming language and JavaScript is browser scripting language.

But, still I think you mean something else, tell your problem clearly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.