User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,394 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,272 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 873 | Replies: 1
Join Date: Dec 2006
Location: in a dream
Posts: 125
Reputation: nschessnerd is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
nschessnerd's Avatar
nschessnerd nschessnerd is offline Offline
Junior Poster

Help java to javascript

  #1  
Jan 4th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 1:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC