List of usage examples for java.lang Short parseShort
public static short parseShort(String s) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { short s = Short.parseShort("10"); System.out.println(s); }
From source file:Main.java
public static void main(String[] args) { System.out.println(Short.parseShort("10")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { short s = Short.parseShort("123"); System.out.println(s);//ww w .jav a2 s . c om }
From source file:com.yahoo.dba.tools.myperfserver.App.java
public static void main(String[] args) throws Exception { //-p --port 9090 //-r --webcontextroot webapps //-l --logpath logpath //-w --war webapp war file name CommandLineParser parser = new GnuParser(); Options options = new Options(); options.addOption("j", "jettyHome", true, "Jetty home, if not set, check system property jetty.home, then default to current Dir"); options.addOption("p", "port", true, "http server port, default to 9090."); options.addOption("c", "webcontextroot", true, "web app url root context, defaul to /"); options.addOption("l", "logpath", true, "log path, default to current directory."); options.addOption("w", "warfile", true, "war file name, default to myperf.war."); options.addOption("k", "workdir", true, "work directory for jetty, default to current dir."); System.out.println(new Date() + " Usage: java -classpath ... com.yahoo.dba.tools.myperfserver.App -j jettyhome -p port -c webcontextroot -k workingDir -l logpath -w war_file"); App myServer = new App(); try {/* w ww .j a v a 2 s . c o m*/ // parse the command line arguments CommandLine line = parser.parse(options, args); // validate that block-size has been set if (line.hasOption("p")) { try { myServer.setPort(Short.parseShort(line.getOptionValue("p"))); } catch (Exception ex) { } } if (line.hasOption("c")) { String val = line.getOptionValue("c"); if (val != null && !val.isEmpty()) myServer.setContextPath(val); } if (line.hasOption("l")) { String val = line.getOptionValue("l"); if (val != null && !val.isEmpty()) myServer.setLogPath(val); } if (line.hasOption("w")) { String val = line.getOptionValue("w"); if (val != null && !val.isEmpty()) myServer.setWarFile(val); } if (line.hasOption("k")) { String val = line.getOptionValue("k"); myServer.setWorkDir(val); } if (line.hasOption("j")) { String val = line.getOptionValue("j"); if (val != null && !val.isEmpty()) myServer.setJettyHome(val); } } catch (ParseException exp) { System.out.println("Unexpected exception:" + exp.getMessage()); } System.setProperty("logPath", myServer.getLogPath()); PID_FILE = myServer.getWarFile().substring(0, myServer.getWarFile().indexOf('.')) + ".pid"; int historyPid = getHistoryPid(); if (historyPid >= 0) { System.out.println(new Date() + " *************************** WARNING *********************"); System.out .println(PID_FILE + " exists. Possibly another instance is still running. PID = " + historyPid); System.out.println(new Date() + " *************************** WARNING *********************"); } if (myServer.startServer()) { pid = getPid(); writePid(); myServer.waitForInterrupt(); removePid(); } else System.out.println("Server not started."); }
From source file:Main.java
public static short doShort(Object obj) { return obj != null ? Short.parseShort(obj.toString()) : 0; }
From source file:Main.java
public static short doShort(Object obj, short defValue) { return obj != null ? Short.parseShort(obj.toString()) : defValue; }
From source file:Main.java
public static final short objectToShort(Object o) { if (o instanceof Number) return ((Number) o).shortValue(); try {//from w w w .jav a 2s . c o m if (o == null) return -1; else return Short.parseShort(o.toString()); } catch (NumberFormatException e) { return -1; } }
From source file:Main.java
public static final short objectToShort(Object o) { if (o instanceof Number) return ((Number) o).shortValue(); try {/*from w ww . j av a2 s . c o m*/ if (o == null) return -1; else return Short.parseShort(o.toString()); } catch (NumberFormatException e) { e.printStackTrace(); return -1; } }
From source file:Main.java
public static short[] parseShortArrayFromHeader(String lineFromHeader) { lineFromHeader = lineFromHeader.replaceAll(",$", ""); lineFromHeader = lineFromHeader.trim(); String[] splitLine = lineFromHeader.split("\\s*,\\s*"); short[] shorts = new short[splitLine.length]; for (int i = 0; i < shorts.length; i++) { shorts[i] = Short.parseShort(splitLine[i]); }//w w w. j a v a 2 s . c o m return shorts; }
From source file:Main.java
/** * parse value to short/* w w w . j av a2 s. c o m*/ */ public static short toShort(String value) { return TextUtils.isEmpty(value) ? 0 : Short.parseShort(value); }