Java tutorial
//package com.java2s; public class Main { private static CharSequence upToCharacter = "."; public static String subString(String string) { if (string == null || string.length() == 0) { return ""; } if (string.contains(upToCharacter)) { int indexOfDot = string.indexOf("."); if (indexOfDot != -1) { return string.substring(0, indexOfDot); } } return ""; } }