replace Line Feed with HTML tags - Android java.lang

Android examples for java.lang:String HTML

Description

replace Line Feed with HTML tags

Demo Code

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

public class Main{

    public static String replaceLineFeed(String input) {
        if (input != null) {
            return input.replace("'", "\\'")
                    .replace("\\r\\n\\r\\n", "</p><p>")
                    .replace("\\n\\n", "</p><p>")
                    .replace("\\r\\n", "<br />").replace("\\n", "<br />");
        } else {/*from w  w w. j  av  a  2  s . c  om*/
            return null;
        }
    }

}

Related Tutorials