Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Distribution License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/org/documents/edl-v10.php. *******************************************************************************/ public class Main { /** * Parses the supplied xsd:byte string and returns its value. * * @param s * A string representation of an xsd:byte value. * @return The <tt>byte</tt> value represented by the supplied string argument. * @throws NumberFormatException * If the supplied string is not a valid xsd:byte value. */ public static byte parseByte(String s) { s = trimPlusSign(s); return Byte.parseByte(s); } /** * Removes the first character from the supplied string if this is a plus sign ('+'). Number strings with * leading plus signs cannot be parsed by methods such as {@link Integer#parseInt(String)}. */ private static String trimPlusSign(String s) { if (s.length() > 0 && s.charAt(0) == '+') { return s.substring(1); } else { return s; } } }