Example usage for java.lang Character toLowerCase

List of usage examples for java.lang Character toLowerCase

Introduction

In this page you can find the example usage for java.lang Character toLowerCase.

Prototype

public static int toLowerCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to lowercase using case mapping information from the UnicodeData file.

Usage

From source file:Main.java

public static void main(String[] argv) {
    System.out.println(Character.toLowerCase('T'));

}

From source file:Main.java

public static void main(String[] args) {
    int cp1 = 0x0050;
    int cp2 = 0x2100;

    int cp3 = Character.toLowerCase(cp1);
    int cp4 = Character.toLowerCase(cp2);

    String str1 = "Lowercase equivalent of cp1 is " + cp3;
    String str2 = "Lowercase equivalent of cp2 is " + cp4;

    System.out.println(str1);//ww w .ja  v a  2 s.  c  om
    System.out.println(str2);
}

From source file:MainClass.java

public static void main(String[] arg) {
    String phrase = "The quick brown fox jumped over the lazy dog.";
    int vowels = 0;
    for (char ch : phrase.toCharArray()) {
        ch = Character.toLowerCase(ch);
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
            ++vowels;//ww  w .  j a v a  2  s  .c  o m
        }
    }
    System.out.println("The phrase contains " + vowels + " vowels.");
}

From source file:StringCharacters.java

public static void main(String[] args) {
    String text = "To be or not to be?";

    int spaces = 0, vowels = 0, letters = 0;

    for (int i = 0; i < text.length(); i++) {
        char ch = Character.toLowerCase(text.charAt(i));
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
            ++vowels;/*w  w  w.j  av  a 2 s.  c  om*/
        if (Character.isLetter(ch))
            ++letters;
        if (Character.isWhitespace(ch))
            ++spaces;
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BufferedReader br = new BufferedReader(new FileReader("in.txt"));
    BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt"));
    int i;//from   w w  w  . j a  v  a2  s.  co  m
    do {
        i = br.read();
        if (i != -1) {
            if (Character.isLowerCase((char) i))
                bw.write(Character.toUpperCase((char) i));
            else if (Character.isUpperCase((char) i))
                bw.write(Character.toLowerCase((char) i));
            else
                bw.write((char) i);
        }
    } while (i != -1);
    br.close();
    bw.close();
}

From source file:Main.java

public static void main(String[] args) {
    // Using the constructor
    Character c1 = new Character('A');

    // Using the factory method - preferred
    Character c2 = Character.valueOf('2');
    Character c3 = Character.valueOf('-');

    // Getting the wrapped char values
    char cc1 = c1.charValue();
    char cc2 = c2.charValue();
    char cc3 = c3.charValue();

    System.out.println("c1 = " + c1);
    System.out.println("c2 = " + c2);
    System.out.println("c3 = " + c3);

    // Using some Character class methods on c1
    System.out.println("isLowerCase c1    = " + Character.isLowerCase(cc1));
    System.out.println("isDigit c1    = " + Character.isDigit(cc1));
    System.out.println("isLetter c1    = " + Character.isLetter(cc1));
    System.out.println("Lowercase of  c1    = " + Character.toLowerCase(cc1));

    // Using some Character class methods on c2
    System.out.println("isLowerCase c2    = " + Character.isLowerCase(cc2));
    System.out.println("isDigit c2    = " + Character.isDigit(cc2));
    System.out.println("isLetter c2    = " + Character.isLetter(cc2));
    System.out.println("Lowercase of  c2    = " + Character.toLowerCase(cc2));

    System.out.println("Uppercase of  c3    = " + Character.toUpperCase(cc3));

}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();

    String hostName = "hostName";
    String fileName = "fileName";

    SSLSocket sslsock = (SSLSocket) factory.createSocket(hostName, 443);

    SSLSession session = sslsock.getSession();
    X509Certificate cert;//from   www.  j av  a2 s  .c o m
    try {
        cert = (X509Certificate) session.getPeerCertificates()[0];
    } catch (SSLPeerUnverifiedException e) {
        System.err.println(session.getPeerHost() + " did not present a valid certificate.");
        return;
    }

    System.out.println(session.getPeerHost() + " has presented a certificate belonging to:");
    Principal p = cert.getSubjectDN();
    System.out.println("\t[" + p.getName() + "]");
    System.out.println("The certificate bears the valid signature of:");
    System.out.println("\t[" + cert.getIssuerDN().getName() + "]");

    System.out.print("Do you trust this certificate (y/n)? ");
    System.out.flush();
    BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
    if (Character.toLowerCase(console.readLine().charAt(0)) != 'y')
        return;

    PrintWriter out = new PrintWriter(sslsock.getOutputStream());

    out.print("GET " + fileName + " HTTP/1.0\r\n\r\n");
    out.flush();

    BufferedReader in = new BufferedReader(new InputStreamReader(sslsock.getInputStream()));
    String line;
    while ((line = in.readLine()) != null)
        System.out.println(line);

    sslsock.close();
}

From source file:KeyEventPost.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    final Text text = new Text(shell, SWT.BORDER);
    text.setSize(text.computeSize(150, SWT.DEFAULT));
    shell.pack();//from   w  ww.  j  av  a2s.co  m
    shell.open();
    new Thread() {
        public void run() {
            String string = "Love the method.";
            for (int i = 0; i < string.length(); i++) {
                char ch = string.charAt(i);
                boolean shift = Character.isUpperCase(ch);
                ch = Character.toLowerCase(ch);
                if (shift) {
                    Event event = new Event();
                    event.type = SWT.KeyDown;
                    event.keyCode = SWT.SHIFT;
                    display.post(event);
                }
                Event event = new Event();
                event.type = SWT.KeyDown;
                event.character = ch;
                display.post(event);
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                }
                event.type = SWT.KeyUp;
                display.post(event);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                }
                if (shift) {
                    event = new Event();
                    event.type = SWT.KeyUp;
                    event.keyCode = SWT.SHIFT;
                    display.post(event);
                }
            }
        }
    }.start();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet146.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 146");
    final Text text = new Text(shell, SWT.BORDER);
    text.setSize(text.computeSize(150, SWT.DEFAULT));
    shell.pack();/*from   www.jav  a  2s.  co  m*/
    shell.open();
    new Thread() {
        @Override
        public void run() {
            // wait for shell to be opened
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }

            String string = "Love the method.";
            for (int i = 0; i < string.length(); i++) {
                char ch = string.charAt(i);
                boolean shift = Character.isUpperCase(ch);
                ch = Character.toLowerCase(ch);
                if (shift) {
                    Event event = new Event();
                    event.type = SWT.KeyDown;
                    event.keyCode = SWT.SHIFT;
                    display.post(event);
                }
                Event event = new Event();
                event.type = SWT.KeyDown;
                event.character = ch;
                display.post(event);
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                }
                event.type = SWT.KeyUp;
                display.post(event);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                }
                if (shift) {
                    event = new Event();
                    event.type = SWT.KeyUp;
                    event.keyCode = SWT.SHIFT;
                    display.post(event);
                }
            }
        }
    }.start();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Main.java

public static String lowerFirst(String str) {
    return Character.toLowerCase(str.charAt(0)) + str.substring(1);
}