Here you can find the source of formatExceptionMsg(String msg)
public static String formatExceptionMsg(String msg)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**//from w ww.jav a 2 s . co m * formats a message that will be displayed in a dialog, * so it's not longer than 80 symbols in each line */ public static String formatExceptionMsg(String msg) { msg = msg.replace("\n", ""); if (msg.length() > 80) { String result = ""; for (int i = 0; i < msg.length(); i = i + 80) { int end = i + 80; if (msg.length() < i + 80) end = msg.length(); String s = msg.substring(i, end); int index = s.lastIndexOf(" "); if (index == -1) { result = result + s + "\n"; } else { result = result + msg.substring(i, i + index) + "\n"; i = i - (s.length() - index); } } return result; } else return msg; } }