Java tutorial
//package com.java2s; public class Main { public static String setDeviceName(String inDeviceName) { try { if (null != inDeviceName && !"".equals(inDeviceName) && inDeviceName.contains("#")) { return inDeviceName.substring(0, inDeviceName.indexOf("#")); } else { return inDeviceName; } } catch (Exception e) { e.printStackTrace(); } return inDeviceName; } }