Source Code : Convert to HTML string

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Convert to HTML string

  

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;

/*
 *  soapUI, copyright (C) 2004-2009 eviware.com 
 *
 *  soapUI is free software; you can redistribute it and/or modify it under the 
 *  terms of version 2.1 of the GNU Lesser General Public License as published by 
 *  the Free Software Foundation.
 *
 *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
 *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 *  See the GNU Lesser General Public License for more details at gnu.org.
 */


public class Utils {
  
  public static String toHtml( String string )
  {
    if( StringUtils.isNullOrEmpty( string ) )
      return "<html><body></body></html>";

    BufferedReader st = new BufferedReader( new StringReader( string ) );
    StringBuffer buf = new StringBuffer( "<html><body>" );

    try
    {
      String str = st.readLine();

      while( str != null )
      {
        if( str.equalsIgnoreCase( "<br/>" ) )
        {
          str = "<br>";
        }

        buf.append( str );

        if( !str.equalsIgnoreCase( "<br>" ) )
        {
          buf.append( "<br>" );
        }

        str = st.readLine();
      }
    }
    catch( IOException e )
    {
      e.printStackTrace();
    }

    buf.append( "</body></html>" );
    string = buf.toString();
    return string;
  }
}

   
    
  

Thank with us