DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   java to javascript (http://www.daniweb.com/forums/thread66361.html)

nschessnerd Jan 4th, 2007 7:53 am
java to javascript
 
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

vishesh Jan 6th, 2007 5:55 am
Re: java to javascript
 
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.


All times are GMT -4. The time now is 2:42 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC