List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:mitm.common.tools.CreateCA.java
public static void main(String[] args) throws Exception { PropertyConfigurator.configure("conf/log4j.properties"); if (args.length != 1) { System.err.println("p12 file expected."); return;/* w w w . j a v a2s . c o m*/ } System.out.println("Please enter your password: "); ConsoleReader consoleReader = new ConsoleReader(new FileInputStream(FileDescriptor.in), new PrintWriter(System.err)); String password = consoleReader.readLine(new Character('*')); CreateCA createCA = new CreateCA(); File p12File = new File(args[0]); createCA.generateCA(password, p12File); System.out.println("CA generated and written to " + p12File.getAbsolutePath()); }
From source file:Main.java
public static String IntToExtHex(int val) { String sample = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; return new Character(sample.charAt((int) (val / 36))).toString() + new Character(sample.charAt(val % 36)).toString(); }
From source file:Main.java
public static String toString(byte b) { StringBuffer sb = new StringBuffer(2); int i = (b & 0xF0) >> 4; int j = b & 0x0F; sb.append(new Character((char) ((i > 9) ? (65 + i - 10) : (48 + i)))); sb.append(new Character((char) ((j > 9) ? (65 + j - 10) : (48 + j)))); return sb.toString(); }
From source file:Main.java
public static Character[] toObjects(String s) { if (s == null) { return null; }//from w w w . java 2 s . c o m int len = s.length(); Character[] array = new Character[len]; for (int i = 0; i < len; i++) { array[i] = new Character(s.charAt(i)); } return array; }
From source file:Main.java
/** * Handles XML encoding of text, e.g. & to & * /* www . jav a 2 s . c om*/ * @param sText Text to XML encode * @return XML Encoded text */ public static String encodeXMLText(String sText) { StringBuffer sBuff2 = new StringBuffer(sText); StringBuffer sNewBuff = new StringBuffer(); for (int i = 0; i < sBuff2.length(); i++) { char currChar = sBuff2.charAt(i); Character currCharObj = new Character(sBuff2.charAt(i)); if (currChar == '&') { if ((sBuff2.length() - 1 - i) >= 4 && sBuff2.charAt(i + 1) == 'a' && sBuff2.charAt(i + 2) == 'm' && sBuff2.charAt(i + 3) == 'p' && sBuff2.charAt(i + 4) == ';') { i = i + 4; sNewBuff.append("&"); } else { sNewBuff.append("&"); } } else if (currChar == '>') { sNewBuff.append(">"); } else if (currChar == '<') { sNewBuff.append("<"); } else { sNewBuff.append(currChar); } } return sNewBuff.toString(); }
From source file:Main.java
public static void staticMethod() { // Creates an Integer object from an int Integer intObj1 = new Integer(100); // Creates an Integer object from a String Integer intObj2 = new Integer("1969"); // Creates a Double object from a double Double doubleObj1 = new Double(10.45); // Creates a Double object from a String Double doubleObj2 = new Double("234.60"); // Creates a Character object from a char Character charObj1 = new Character('A'); // Creates a Boolean object from a boolean Boolean booleanObj1 = new Boolean(true); // Creates Boolean objects from Strings Boolean booleanTrue = new Boolean("true"); Boolean booleanFalse = new Boolean("false"); }
From source file:Main.java
public static String stripNonValidXMLCharacters(String in) { StringBuffer out = new StringBuffer(); // Used to hold the output. char current; // Used to reference the current character. if (in == null || ("".equals(in))) return ""; // vacancy test. for (int i = 0; i < in.length(); i++) { current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen. if ((current == 0x9) || (current == 0xA) || (current == 0xD) || ((current >= 0x20) && (current <= 0xD7FF)) || ((current >= 0xE000) && (current <= 0xFFFD)) || ((current >= 0x10000) && (current <= 0x10FFFF))) { out.append(current);//from w w w .ja v a2 s . co m } else { Log.e("Falmarri", "Not a valid character " + new Character(current)); } } return out.toString(); }
From source file:Main.java
public static String decode(String entity) { if (entity.charAt(entity.length() - 1) == ';') // remove trailing // semicolon entity = entity.substring(0, entity.length() - 1); if (entity.charAt(1) == '#') { int start = 2; int radix = 10; if (entity.charAt(2) == 'X' || entity.charAt(2) == 'x') { start++;// w ww .j a v a2 s. c o m radix = 16; } Character c = new Character((char) Integer.parseInt(entity.substring(start), radix)); return c.toString(); } else { String s = decoder.get(entity); if (s != null) return s; else return ""; } }
From source file:Main.java
public static Character[] StringToCharacterArray(String s) { Character[] cArray = new Character[s.length()]; for (int i = 0; i < s.length(); i++) { cArray[i] = new Character(s.charAt(i)); }//from w ww. j a va 2 s .c o m return cArray; }
From source file:Main.java
/** * This helper takes a String escaped according to escape and undos the escape. * FIXME This is not complete at all./*from w w w . ja v a 2s .c o m*/ * * @param enc the escaped String * @return the original String * @see #escape */ @SuppressWarnings("fallthrough") public static final String descape(String enc) { StringBuilder ret = new StringBuilder(enc.length()); // same length for (int i = 0; i < enc.length(); ++i) { char c = enc.charAt(i); switch (c) { case '&': if (enc.charAt(i + 1) == '#') { i += 3; // we simply believe that the next two are going to be #x. FIXME? String s = enc.substring(i); int colonIndex = s.indexOf(';'); int v = Integer.parseInt(s.substring(0, colonIndex), 16); ret.append(new Character((char) v)); i += colonIndex; break; } // else run-through default: ret.append(c); break; } } return ret.toString(); }