List of usage examples for java.text CharacterIterator current
public char current();
From source file:Main.java
public static void main(String[] argv) throws Exception { CharacterIterator it = new StringCharacterIterator("abcd"); char ch = it.first(); ch = it.current(); ch = it.next();//w w w . ja v a 2 s . c om ch = it.current(); ch = it.last(); int pos = it.getIndex(); ch = it.next(); pos = it.getIndex(); ch = it.previous(); ch = it.setIndex(1); }
From source file:Main.java
public static void main(String[] argv) throws Exception { CharacterIterator it = new StringCharacterIterator("abcd"); ((StringCharacterIterator) it).setText("efgh"); char ch = it.current(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { CharacterIterator it = new StringCharacterIterator("abcd"); int begin = 5; int end = 9;//ww w. j av a 2 s . c o m int pos = 6; it = new StringCharacterIterator("abcd efgh ijkl", begin, end, pos); char ch = it.current(); System.out.println(ch); ch = it.last(); System.out.println(ch); }
From source file:Main.java
public static String encode(String unencodedValue) { CharacterIterator charIterator; StringBuilder encodeBuilder;//from w ww . j a v a2s.co m char currentChar; encodeBuilder = new StringBuilder(); charIterator = new StringCharacterIterator(unencodedValue); while ((currentChar = charIterator.current()) != CharacterIterator.DONE) { switch (currentChar) { case '&': encodeBuilder.append("&"); break; case '<': encodeBuilder.append("<"); break; case '>': encodeBuilder.append(">"); break; default: encodeBuilder.append(currentChar); } charIterator.next(); } return encodeBuilder.toString(); }