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

Member Avatar for GreenDay2001

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.