Here you can find the source of breakString(String string, int l, String newLine)
Parameter | Description |
---|---|
string | The String. |
l | The desired long. |
newLine | The newline char, can be: \n or $lt;br/> |
public static final String breakString(String string, int l, String newLine)
//package com.java2s; public class Main { /**//from www.ja v a 2 s. c om * Breaks a String for showing. Breaking a String its just inserting a new * line character inside the text at a specified position, in order for the * string to spawn 2 lines instead of just 1 very long line. * * @param string The String. * @param l The desired long. * @param newLine The newline char, can be: \n or $lt;br/> * * @return The trimmed URL. */ public static final String breakString(String string, int l, String newLine) { int length = (l == 0) ? 80 : l; int inserts = string.length() / length; StringBuilder b = new StringBuilder(string); for (int k = 0; k < inserts; k++) { b.insert(length * (k + 1), newLine); } return b.toString(); } }