Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String deleteSpace(String str) { if (str.startsWith(" ")) { str = str.substring(1, str.length()).trim(); } else if (str.endsWith(" ")) { str = str.substring(0, str.length() - 1).trim(); } return str; } }