Java tutorial
//package com.java2s; public class Main { public static String GetDisplayTitle(String alias, String creditCode) { StringBuffer sb = new StringBuffer(); if (alias != null && alias.trim() != "") { sb.append("["); sb.append(alias.trim()); sb.append("] "); } if (creditCode != null && creditCode.trim() != "") { if (creditCode.length() > 10) { sb.append(creditCode.substring(0, 6)); sb.append("..."); sb.append(creditCode.substring(creditCode.length() - 4, 4)); } else sb.append(creditCode); } return sb.toString(); } }