Example usage for java.text CharacterIterator last

List of usage examples for java.text CharacterIterator last

Introduction

In this page you can find the example usage for java.text CharacterIterator last.

Prototype

public char last();

Source Link

Document

Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position.

Usage

From source file:Main.java

public static void main(String[] args) {
    CharacterIterator it = new StringCharacterIterator(text);

    for (char ch = it.last(); ch != CharacterIterator.DONE; ch = it.previous()) {
        System.out.print(ch);/*from ww w  .j a  v a2 s .c  o  m*/
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    CharacterIterator it = new StringCharacterIterator("abcd");

    for (char ch = it.last(); ch != CharacterIterator.DONE; ch = it.previous()) {
        System.out.println(ch);/*from  w  ww  .j a  va 2s .  c  o m*/
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Format formatter = new SimpleDateFormat("MMM");
    CharacterIterator s = formatter.formatToCharacterIterator(new Date());
    System.out.println(s.last());
}

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();/*from  w w  w.j  a v a2s  .  c  o m*/
    ch = it.next();
    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");

    int begin = 5;
    int end = 9;// ww w .  j  a  va  2s .com
    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:com.woonoz.proxy.servlet.UrlRewriterImpl.java

private static String removeTrailingSlashes(final String text) {
    if (text.isEmpty()) {
        return text;
    }/*from w w  w .j av  a  2s. c om*/
    final CharacterIterator it = new StringCharacterIterator(text);
    Character c = it.last();
    while (c.equals('/')) {
        c = it.previous();
    }
    return text.substring(0, it.getIndex() + 1);
}