List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:com.shuzhilian.icu.license.LicenseGenerator.java
public static void main(String[] args) throws IOException, ParseException { if (args.length != 6) { System.out.println(/* w w w .java 2s . c o m*/ "Args: propties_file license_path license_name license_password private_key_file private_key_password"); return; } String prop = args[0]; String path = args[1]; String name = args[2]; String pawd = args[3]; String pk = args[4]; String pkpd = args[5]; LicenseGenerator generator = new LicenseGenerator(); generator.startUp(new File(pk), pkpd.toCharArray()); Properties conf = new Properties(); conf.load(new FileInputStream(new File(prop))); generator.generateLicense(path, name, pawd.toCharArray(), conf); }
From source file:Main.java
public static void main(String args[]) throws IOException { String data, answer = ""; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter any String : "); data = br.readLine();// www . ja v a 2 s .c o m char[] findupper = data.toCharArray(); for (int i = 0; i < findupper.length; i++) { if (findupper[i] >= 65 && findupper[i] <= 91) // ascii value in between 65 // and 91 is A to Z { answer += findupper[i]; // adding only uppercase } } System.out.println("Answer : " + answer); }
From source file:edu.msu.cme.rdp.graph.sandbox.BloomFilterInterrogator.java
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("USAGE: BloomFilterStats <bloom_filter>"); System.exit(1);/* w ww. j a v a 2 s . c o m*/ } File bloomFile = new File(args[0]); ObjectInputStream ois = ois = new ObjectInputStream( new BufferedInputStream(new FileInputStream(bloomFile))); BloomFilter filter = (BloomFilter) ois.readObject(); ois.close(); printStats(filter, System.out); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String line; CodonWalker walker = null; while ((line = reader.readLine()) != null) { char[] kmer = line.toCharArray(); System.out.print(line + "\t"); try { walker = filter.new RightCodonFacade(kmer); walker.jumpTo(kmer); System.out.print("present"); } catch (Exception e) { System.out.print("not present\t" + e.getMessage()); } System.out.println(); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { KeyGenerator kg = KeyGenerator.getInstance("DESede"); Key sharedKey = kg.generateKey(); String password = "password"; byte[] salt = "salt1234".getBytes(); PBEParameterSpec paramSpec = new PBEParameterSpec(salt, 20); PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray()); SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); SecretKey passwordKey = kf.generateSecret(keySpec); Cipher c = Cipher.getInstance("PBEWithMD5AndDES"); c.init(Cipher.WRAP_MODE, passwordKey, paramSpec); byte[] wrappedKey = c.wrap(sharedKey); c = Cipher.getInstance("DESede"); c.init(Cipher.ENCRYPT_MODE, sharedKey); byte[] input = "input".getBytes(); byte[] encrypted = c.doFinal(input); c = Cipher.getInstance("PBEWithMD5AndDES"); c.init(Cipher.UNWRAP_MODE, passwordKey, paramSpec); Key unwrappedKey = c.unwrap(wrappedKey, "DESede", Cipher.SECRET_KEY); c = Cipher.getInstance("DESede"); c.init(Cipher.DECRYPT_MODE, unwrappedKey); System.out.println(new String(c.doFinal(encrypted))); }
From source file:com.shuzhilian.icu.license.LicenseViewer.java
public static void main(String[] args) { if (args.length != 4) { System.out.println("Args: publicKey keyPassword licenseName licensePassword"); return;//from w w w. j a v a 2 s .c o m } String keyFile = args[0]; String keyPwd = args[1]; String license = args[2]; String licPwd = args[3]; LicenseViewer viewer = new LicenseViewer(); viewer.startUp(new File(keyFile), keyPwd.toCharArray(), licPwd.toCharArray()); viewer.printLicense(license); }
From source file:gov.nih.nci.cadsr.cadsrpasswordchange.core.OracleObfuscation.java
public static void main(String[] args) throws Exception { OracleObfuscation x = new OracleObfuscation("$_12345&"); // just a // random/*from w w w . ja va 2 s. c om*/ // pick for // testing String text = CommonUtil.pad("BB", Constants.MAX_ANSWER_LENGTH); //args[0]; byte[] encrypted = x.encrypt(text.getBytes()); String encoded = new String(Hex.encodeHex(encrypted)); System.out.println("Encrypted/Encoded: \"" + encoded + "\""); byte[] decoded = Hex.decodeHex(encoded.toCharArray()); String decrypted = new String(x.decrypt(decoded)); // String decrypted = new String(x.decrypt(encrypted)); System.out.println("Decoded/Decrypted: \"" + decrypted + "\""); }
From source file:com.lhings.java.utils.ByteMan.java
public static void main(String[] args) throws DecoderException { byte[] a = { (byte) 0x12, (byte) 0xfa, (byte) 0xa4, (byte) 0xc5 }; for (byte b : a) System.out.print(b + ", "); System.out.println();/*from w ww . jav a 2 s. com*/ String str = Hex.encodeHexString(a); System.out.println(str); byte[] c = Hex.decodeHex(str.toCharArray()); for (byte b : c) System.out.print(b + ", "); System.out.println(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String os = "abc"; for (byte b : os.getBytes("UTF-16BE")) { System.out.println(b);/*from w w w.j a va2 s .c o m*/ } ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for (char c : os.toCharArray()) { dos.writeChar(c); } byte[] ba = baos.toByteArray(); for (byte b : ba) { System.out.println(b); } }
From source file:com.tc.simple.apn.quicktests.Test.java
/** * @param args// www .j ava2 s . c o m */ public static void main(String[] args) { SSLSocket socket = null; try { String host = "gateway.sandbox.push.apple.com"; int port = 2195; String token = "de7f197546e41a76684f8e2d89f397ed165298d7772f4bd9b0f39c674b185b0f"; System.out.println(token.toCharArray().length); //String token = "8cebc7c08f79fa62f0994eb4298387ff930857ff8d14a50de431559cf476b223"; KeyStore keyStore = KeyStore.getInstance("PKCS12"); keyStore.load(Test.class.getResourceAsStream("egram-dev-apn.p12"), "xxxxxxxxx".toCharArray()); KeyManagerFactory keyMgrFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyMgrFactory.init(keyStore, "xxxxxxxxx".toCharArray()); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(keyMgrFactory.getKeyManagers(), null, null); SSLSocketFactory socketFactory = sslContext.getSocketFactory(); socket = (SSLSocket) socketFactory.createSocket(host, port); String[] cipherSuites = socket.getSupportedCipherSuites(); socket.setEnabledCipherSuites(cipherSuites); socket.startHandshake(); char[] t = token.toCharArray(); byte[] b = Hex.decodeHex(t); OutputStream outputstream = socket.getOutputStream(); String payload = "{\"aps\":{\"alert\":\"yabadabadooo\"}}"; int expiry = (int) ((System.currentTimeMillis() / 1000L) + 7200); ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bout); //command dos.writeByte(1); //id dos.writeInt(900); //expiry dos.writeInt(expiry); //token length. dos.writeShort(b.length); //token dos.write(b); //payload length dos.writeShort(payload.length()); //payload. dos.write(payload.getBytes()); byte[] byteMe = bout.toByteArray(); socket.getOutputStream().write(byteMe); socket.setSoTimeout(900); InputStream in = socket.getInputStream(); System.out.println(APNErrors.getError(in.read())); in.close(); outputstream.close(); } catch (Exception e) { e.printStackTrace(); } finally { try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.example.java.collections.ArrayExample.java
public static void main(String[] args) { /* ########################################################### */ // Initializing an Array String[] creatures = { "goldfish", "oscar", "guppy", "minnow" }; int[] numbers = new int[10]; int counter = 0; while (counter < numbers.length) { numbers[counter] = counter;// w w w . ja v a2s . c o m System.out.println("number[" + counter + "]: " + counter); counter++; } for (int theInt : numbers) { System.out.println(theInt); } //System.out.println(numbers[numbers.length]); /* ########################################################### */ /* ########################################################### */ // Using Charecter Array String name = "Michael"; // Charecter Array char[] charName = name.toCharArray(); System.out.println(charName); // Array Fuctions char[] html = new char[] { 'M', 'i', 'c', 'h', 'a', 'e', 'l' }; char[] lastFour = new char[4]; System.arraycopy(html, 3, lastFour, 0, lastFour.length); System.out.println(lastFour); /* ########################################################### */ /* ########################################################### */ // Using Arrays of Other Types Object[] person = new Object[] { "Michael", new Integer(94), new Integer(1), new Date() }; String fname = (String) person[0]; //ok Integer age = (Integer) person[1]; //ok Date start = (Date) person[2]; //oops! /* ########################################################### */ /* ########################################################### */ // Muti Dimestional Array String[][] bits = { { "Michael", "Ernest", "MFE" }, { "Ernest", "Friedman-Hill", "EFH" }, { "Kathi", "Duggan", "KD" }, { "Jeff", "Kellum", "JK" } }; bits[0] = new String[] { "Rudy", "Polanski", "RP" }; bits[1] = new String[] { "Rudy", "Washington", "RW" }; bits[2] = new String[] { "Rudy", "O'Reilly", "RO" }; /* ########################################################### */ /* ########################################################### */ //Create ArrayList from array String[] stringArray = { "a", "b", "c", "d", "e" }; ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray)); System.out.println(arrayList); // [a, b, c, d, e] /* ########################################################### */ /* ########################################################### */ //Check if an array contains a certain value String[] stringArray1 = { "a", "b", "c", "d", "e" }; boolean b = Arrays.asList(stringArray).contains("a"); System.out.println(b); // true /* ########################################################### */ /* ########################################################### */ //Concatenate two arrays int[] intArray = { 1, 2, 3, 4, 5 }; int[] intArray2 = { 6, 7, 8, 9, 10 }; // Apache Commons Lang library int[] combinedIntArray = ArrayUtils.addAll(intArray, intArray2); /* ########################################################### */ /* ########################################################### */ //Joins the elements of the provided array into a single String // Apache common lang String j = StringUtils.join(new String[] { "a", "b", "c" }, ", "); System.out.println(j); // a, b, c /* ########################################################### */ /* ########################################################### */ //Covnert ArrayList to Array String[] stringArray3 = { "a", "b", "c", "d", "e" }; ArrayList<String> arrayList1 = new ArrayList<String>(Arrays.asList(stringArray)); String[] stringArr = new String[arrayList.size()]; arrayList.toArray(stringArr); for (String s : stringArr) { System.out.println(s); } /* ########################################################### */ /* ########################################################### */ //Convert Array to Set Set<String> set = new HashSet<String>(Arrays.asList(stringArray)); System.out.println(set); //[d, e, b, c, a] /* ########################################################### */ /* ########################################################### */ //Reverse an array int[] intArray1 = { 1, 2, 3, 4, 5 }; ArrayUtils.reverse(intArray1); System.out.println(Arrays.toString(intArray1)); //[5, 4, 3, 2, 1] /* ########################################################### */ /* ########################################################### */ // Remove element of an array int[] intArray3 = { 1, 2, 3, 4, 5 }; int[] removed = ArrayUtils.removeElement(intArray3, 3);//create a new array System.out.println(Arrays.toString(removed)); /* ########################################################### */ /* ########################################################### */ byte[] bytes = ByteBuffer.allocate(4).putInt(8).array(); for (byte t : bytes) { System.out.format("0x%x ", t); } /* ########################################################### */ }