Java tutorial
//package com.java2s; public class Main { /** * Freaking Java trim won't work!!! This is an own implementation of trim. * * @return String with all fields separated by ":" */ public static String trimmer(String line) { String retval = ""; Boolean series = false; for (Character a : line.toCharArray()) { if (!a.equals(' ') && !series) retval += a; if (!a.equals(' ') && series) { retval += ":" + a; series = false; } if (a.equals(' ')) { series = true; } } return retval; } }