List of usage examples for java.lang Integer toHexString
public static String toHexString(int i)
From source file:Snippet25.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Listener listener = new Listener() { public void handleEvent(Event e) { String string = e.type == SWT.KeyDown ? "DOWN:" : "UP :"; string += " stateMask=0x" + Integer.toHexString(e.stateMask) + stateMask(e.stateMask) + ","; string += " keyCode=0x" + Integer.toHexString(e.keyCode) + " " + keyCode(e.keyCode) + ","; string += " character=0x" + Integer.toHexString(e.character) + " " + character(e.character); System.out.println(string); }// w w w .j av a2s. c o m }; shell.addListener(SWT.KeyDown, listener); shell.addListener(SWT.KeyUp, listener); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.payne.test.StringTest.java
public static void main(String[] args) throws IOException { // String a = "160504185452148809-1"; // a = a.split("-")[0]; // System.out.println(a); // Random r = new Random(); // long a = 0l; // for(int i=0;i<10000;i++){ // a = r.nextInt(5001) + 5000; // if(a==5000){ // System.out.println(a); // } // }//from w ww. j a v a 2 s . c om /** * ???? */ // List<Integer> numberList = new ArrayList<>(); // numberList.add(1); // numberList.add(2); // Integer[] numbers = numberList.toArray(new Integer[numberList.size()]); //// int[] numbers = new int[]{1,2}; // // System.out.println(new Integer[]{}.length==0?0:1); // // Student s = new Student(); // s.sumUp(new Integer[]{}.length==0?numbers:new Integer[]{1}); // s.sumUp(numbers); // Parent p = null; // Parent p2 = new Parent(new Student(5)); // // Student s = new Student(); // p = s.print(p); // System.out.println(p==null?0:1); // System.out.println(p.getAge()); // System.out.println(p.getStudent().getAge()); // int ai = 0; // for(int i=0;i<2;i++){ // int b = 0; // int b_grow = 0; // for(int j=0;j<5;j++){ // b += new Random().nextInt(5); // } // // } // // // System.out.println(UUID.randomUUID().toString()); // int a = 1; // a = doAdd(a); // System.out.println(a); Pattern p = Pattern.compile("^\\d{1,9}(.\\d{1,2})?$"); Matcher m = p.matcher("666666541.13"); boolean b = m.matches(); System.out.println(b); // System.out.println(-2>>4); // BigDecimal b = new BigDecimal(100.50); // System.out.println(b.toString()); // indexOf ?? // String a = "?"; // // String[] split = a.split("?"); // if(a.indexOf("?")>-1){ // System.out.println("111"); // } // for(String s: split){ // System.out.println(s); // } // MapTestObject mto = new MapTestObject(); // mto.setOrderType(OrderType.TWO); // // String str = "\":\""; // System.out.println(str); // String a = ","; //// // String[] splits = a.split("."); // List<String> asList = Arrays.asList(splits); // String last = ""; // String last = ""; // String last = ""; // if (!asList.isEmpty()) { // if (asList.indexOf(last) > -1) { // int indexOf = asList.indexOf(last); // if (indexOf + 1 >= asList.size()) { // System.out.println("?"); // }else{ // String next = asList.get(indexOf + 1); // if (OTHERStringUtils.isEmpty(next)) { // System.out.println("?"); // } else { // System.out.println("?" + next); // } // } // } else { // System.out.println("?"); // } // } else { // System.out.println("??"); // } // System.out.println("?\",\""); // String a ="1123"; // a = StringUtils.substring(a, 0, a.length()-1); // System.out.println("a="+a); // int a = 0x12345678; ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeInt(a); System.out.println(Integer.toHexString(a)); byte[] c = baos.toByteArray(); for (int i = 0; i < 4; i++) { System.out.println(Integer.toHexString(c[i])); } }
From source file:org.eclipse.swt.snippets.Snippet25.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 25"); Listener listener = e -> {/*from w w w . j a va2 s . c o m*/ String string = e.type == SWT.KeyDown ? "DOWN:" : "UP :"; string += " stateMask=0x" + Integer.toHexString(e.stateMask) + stateMask(e.stateMask) + ","; string += " keyCode=0x" + Integer.toHexString(e.keyCode) + " " + keyCode(e.keyCode) + ","; string += " character=0x" + Integer.toHexString(e.character) + " " + character(e.character); if (e.keyLocation != 0) { string += " location="; if (e.keyLocation == SWT.LEFT) string += "LEFT"; if (e.keyLocation == SWT.RIGHT) string += "RIGHT"; if (e.keyLocation == SWT.KEYPAD) string += "KEYPAD"; } System.out.println(string); }; shell.addListener(SWT.KeyDown, listener); shell.addListener(SWT.KeyUp, listener); shell.setLayout(new FillLayout()); shell.setSize(200, 200); Label label = new Label(shell, SWT.WRAP); label.setText("Start typing to see key state, code and character in console."); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:KeyCodeCharacterState.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Listener listener = new Listener() { public void handleEvent(Event e) { String string = e.type == SWT.KeyDown ? "DOWN:" : "UP :"; string += " stateMask=0x" + Integer.toHexString(e.stateMask) + stateMask(e.stateMask) + ","; string += " keyCode=0x" + Integer.toHexString(e.keyCode) + " " + keyCode(e.keyCode) + ","; string += " character=0x" + Integer.toHexString(e.character) + " " + character(e.character); System.out.println(string); }/*from w w w . ja va 2s. c o m*/ }; shell.addListener(SWT.KeyDown, listener); shell.addListener(SWT.KeyUp, listener); shell.setSize(200, 200); shell.setText("Press Key on the blank window"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.tiempometa.thingmagic.ReadTest.java
public static void main(String argv[]) { // Program setup Reader r = null;//from w w w . j a va 2 s . co m 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:Main.java
public static String paddedByteString(byte b) { return Integer.toHexString((b | 256) & 511).toUpperCase().substring(1); }
From source file:Main.java
public static String toUuid16(int assignedNumber) { return Integer.toHexString(assignedNumber); }
From source file:Main.java
public static String convertIntToHexString(int i) { return Integer.toHexString(i); }
From source file:Main.java
public static String byteToHexString(byte b) { return Integer.toHexString(byte2Int(b)); }
From source file:Main.java
public static byte intToByte(int i) { return Integer.valueOf(Integer.toHexString(i), 16).byteValue(); }