List of usage examples for java.lang Long parseLong
public static long parseLong(String s, int radix) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { System.out.println(Long.parseLong("10", 8)); }
From source file:Main.java
public static void main(String args[]) { Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("FALSE"); System.out.println(b1.toString() + " or " + b2.toString()); for (int j = 0; j < 16; ++j) System.out.print(Character.forDigit(j, 16)); Integer i = new Integer(Integer.parseInt("ef", 16)); Long l = new Long(Long.parseLong("abcd", 16)); long m = l.longValue() * i.longValue(); System.out.println(Long.toString(m, 8)); }
From source file:Main.java
public static void main(String args[]) { Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("FALSE"); System.out.println(b1.toString() + " or " + b2.toString()); for (int j = 0; j < 16; ++j) System.out.print(Character.forDigit(j, 16)); Integer i = new Integer(Integer.parseInt("ef", 16)); Long l = new Long(Long.parseLong("abcd", 16)); long m = l.longValue() * i.longValue(); System.out.println(Long.toString(m, 8)); System.out.println(Float.MIN_VALUE); System.out.println(Double.MAX_VALUE); }
From source file:WrappedClassApp.java
public static void main(String args[]) { Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("FALSE"); System.out.println(b1.toString() + " or " + b2.toString()); for (int j = 0; j < 16; ++j) System.out.print(Character.forDigit(j, 16)); System.out.println();/*from w ww . jav a 2 s . com*/ Integer i = new Integer(Integer.parseInt("ef", 16)); Long l = new Long(Long.parseLong("abcd", 16)); long m = l.longValue() * i.longValue(); System.out.println(Long.toString(m, 8)); System.out.println(Float.MIN_VALUE); System.out.println(Double.MAX_VALUE); }
From source file:com.zookeeper.zkadmin.util.ZK_ZxidUtils.java
public static void main(String[] args) { System.out.println(1 << 32); System.out.println(1L << 32); System.out.println(makeZxid(1, 268435457)); long l = Long.parseLong(StringUtils.substring("0x10000001", 2), 16); System.out.println(getCounterFromZxid(l)); System.out.println(getEpochFromZxid(l)); System.out.println(0xffffffffL); }
From source file:fr.romainf.QRCode.java
public static void main(String[] args) { Options options = buildOptions();/*from ww w . j av a 2s. co m*/ CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(options, args); args = cmd.getArgs(); int l = args.length; if (l != 1) { System.out.println("Can only encode one datum at a time (" + l + " given)"); printUsage(options); System.exit(1); } if (cmd.hasOption("help")) { printUsage(options); System.exit(0); } String output = cmd.getOptionValue("o", DEFAULT_OUTPUT_FILE); String pixelColourText = cmd.getOptionValue("c", DEFAULT_PIXEL_COLOUR); if (pixelColourText.startsWith("0x")) { pixelColourText = pixelColourText.substring(2); } Color pixelColour; if (pixelColourText.length() == 6) { pixelColour = new Color(Integer.parseInt(pixelColourText, 16)); } else { pixelColour = new Color((int) Long.parseLong(pixelColourText, 16), true); } writeQRCode(args[l - 1], output, pixelColour); } catch (ParseException e) { System.out.println(e.getMessage()); printUsage(options); System.exit(1); } catch (WriterException e) { System.out.println("Could not create QRCode from data (" + e.getMessage() + ")"); System.exit(2); } catch (IOException e) { System.out.println("Could not save QRCode to file (" + e.getMessage() + ")"); System.exit(4); } System.exit(0); }
From source file:com.tiempometa.thingmagic.ReadTest.java
public static void main(String argv[]) { // Program setup Reader r = null;//w ww . j a v a 2 s . c om int nextarg = 0; boolean trace = false; if (argv.length < 1) usage(); if (argv[nextarg].equals("-v")) { trace = true; nextarg++; } // Create Reader object, connecting to physical device try { TagReadData[] tagReads; String uri = argv[nextarg]; System.out.println("Creating reader with " + uri); r = Reader.create(uri); System.out.println("Setting trace..."); // if (trace) { // setTrace(r, new String[] { "on" }); // } System.out.println("Connecting..."); r.connect(); System.out.println("Connected!"); if (Reader.Region.UNSPEC == (Reader.Region) r.paramGet("/reader/region/id")) { Reader.Region[] supportedRegions = (Reader.Region[]) r .paramGet(TMConstants.TMR_PARAM_REGION_SUPPORTEDREGIONS); if (supportedRegions.length < 1) { throw new Exception("Reader doesn't support any regions"); } else { r.paramSet("/reader/region/id", supportedRegions[0]); } } r.addReadListener(new TagReadListener()); int count = 0; while (runMe) { // Read tags tagReads = r.read(500); // Print tag reads Long password = null; Long killword = null; for (TagReadData tr : tagReads) { p(tr.toString()); try { String accessCode = readAccess(tr, r); password = Long.parseLong(accessCode, 16); p("Password " + password); p("--" + Long.toHexString(password)); accessCode = readKill(tr, r); killword = Long.parseLong(accessCode, 16); p("Killword " + killword); p("--" + Long.toHexString(killword)); // if (password == 0) { p("Setting password"); password = 0xAFCC01ACl; short[] access = new short[2]; access[1] = (short) 0x01AC; access[0] = (short) 0xAFCC; p("Setting password to "); for (short word : access) { System.out.printf("%04X", word); } p("\n"); writeAccess(access, tr, r); // } // if (killword == 0) { p("Setting killword"); killword = 0xADD001ACl; access = new short[2]; access[1] = (short) 0x01AC; access[0] = (short) 0xADD0; p("Setting killword to "); for (short word : access) { System.out.printf("%04X", word); } p("\n"); writeKill(access, tr, r); // } if (count < 10) { p("Waiting to lock " + (10 - count)); } else if (count == 10) { p("Locking..." + password.intValue()); p("--" + Long.toHexString(password)); lockTag(password.intValue(), new LockAction(LockAction.KILL_LOCK), tr, r); p("Locked kill"); lockTag(password.intValue(), new LockAction(LockAction.ACCESS_LOCK), tr, r); p("Locked access"); } else { p("Done with this tag"); } count++; } catch (ReaderException e) { System.out.println("Exception : " + e.getMessage()); killword = 0xADD001ACl; password = 0xAFCC01ACl; if (count < 20) { p("Waiting to unlock " + (20 - count)); } else if (count == 20) { p("Unlocking..."); p("Password :" + password.intValue()); p("--" + Integer.toHexString(password.intValue())); lockTag(password.intValue(), new LockAction(LockAction.ACCESS_UNLOCK), tr, r); p("Unlocked access"); lockTag(password.intValue(), new LockAction(LockAction.KILL_UNLOCK), tr, r); p("Unlocked kill"); p("***Unlocked"); p("Locking..."); p("Password :" + password.intValue()); lockTag(password.intValue(), new LockAction(LockAction.KILL_LOCK), tr, r); p("Locked kill"); lockTag(password.intValue(), new LockAction(LockAction.ACCESS_LOCK), tr, r); p("Locked access"); } else if (count == 30) { p("Killing"); p("Unlocking access"); lockTag(password.intValue(), new LockAction(LockAction.KILL_UNLOCK), tr, r); p("Issuing kill command"); killTag(killword.intValue(), tr, r); } else { p("Waiting to kill"); } count++; } } } // Shut down reader r.destroy(); } catch (ReaderException re) { System.out.println("Reader Exception : " + re.getMessage()); } catch (Exception re) { System.out.println("Exception : " + re.getLocalizedMessage()); System.out.println("Exception : " + re.getMessage()); } finally { r.destroy(); } }
From source file:lu.tudor.santec.dicom.gui.header.Dcm2Xml.java
public static void main(String[] args) { CommandLine cl = parse(args);/*from ww w . j a va 2 s . com*/ Dcm2Xml dcm2xml = new Dcm2Xml(); File ifile = new File((String) cl.getArgList().get(0)); File ofile = null; if (cl.hasOption("o")) { ofile = new File(cl.getOptionValue("o")); dcm2xml.setBaseDir(ofile.getAbsoluteFile().getParentFile()); } if (cl.hasOption("d")) { dcm2xml.setBaseDir(new File(cl.getOptionValue("d"))); } boolean x = cl.hasOption("X"); if (cl.hasOption("x")) { String[] tagStr = cl.getOptionValues("x"); int[] excludes = new int[x ? tagStr.length + 1 : tagStr.length]; for (int i = 0; i < tagStr.length; i++) { try { excludes[i] = (int) Long.parseLong(tagStr[i], 16); } catch (NumberFormatException e) { excludes[i] = Tag.forName(tagStr[i]); } } if (x) { excludes[tagStr.length] = Tag.PixelData; } dcm2xml.setExclude(excludes); } else if (x) { dcm2xml.setExclude(new int[] { Tag.PixelData }); } if (cl.hasOption("T")) { final String xslurl = cl.getOptionValue("T"); try { dcm2xml.setXslt(new URL(xslurl)); } catch (MalformedURLException e) { System.err.println("dcm2xml: invalid xsl URL: " + xslurl); System.exit(1); } dcm2xml.setXsltInc(cl.hasOption("I")); dcm2xml.setXsltParams(cl.getOptionValues("P")); } dcm2xml.setComments(cl.hasOption("C")); dcm2xml.setIndent(!cl.hasOption("c")); long t1 = System.currentTimeMillis(); try { dcm2xml.convert(ifile, ofile); } catch (TransformerConfigurationException e) { System.err.println("dcm2xml: Configuration Error: " + e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("dcm2xml: Failed to convert " + ifile + ": " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } long t2 = System.currentTimeMillis(); if (ofile != null) System.out.println("Finished conversion of " + ifile + "to " + ofile + " in " + (t2 - t1) + "ms"); }
From source file:Main.java
public static int HexToInt(String hex) { return (int) Long.parseLong(hex, 16); }
From source file:Main.java
public static long strTolong(String str) { try {//ww w .ja v a 2 s. c o m return Long.parseLong(str, 10); } catch (Exception e) { return 0; } }