Java tutorial
public class Main { public static void main(String[] a) { StringBuilder builder = new StringBuilder("Line 1\n"); builder.append("Line 3\n"); String lineToInsert = "Line 2\n"; builder.insert(0, lineToInsert); System.out.println(builder.toString()); } } /* Line 2 Line 1 Line 3 */