Example usage for java.lang String toUpperCase

List of usage examples for java.lang String toUpperCase

Introduction

In this page you can find the example usage for java.lang String toUpperCase.

Prototype

public String toUpperCase() 

Source Link

Document

Converts all of the characters in this String to upper case using the rules of the default locale.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    System.setErr(new PrintStream(new FileOutputStream("system_err.txt")));

    String nullString = null;
    nullString = nullString.toUpperCase();
}

From source file:Main.java

public static void main(String[] args) {

    String str = "this is a test";

    str = str.toUpperCase();

    System.out.println(str);//from  w  ww  . ja v  a2s.c  om
}

From source file:Main.java

public static void main(String[] argv) {
    String str = "Java2s.Com";
    System.out.println(str.toUpperCase());

}

From source file:Main.java

public static void main(String[] args) {
    String str = "string";
    String strUpper = str.toUpperCase();
    System.out.println(str);// w w w  .  j a  va 2 s  . c om
    System.out.println(strUpper);
}

From source file:MainClass.java

public static void main(String args[]) {
    String org = "This is a test. This is, too.    ";
    System.out.println(org.toUpperCase());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String string = "This is a test";
    // Convert to upper case
    String upper = string.toUpperCase();

    // Convert to lower case
    String lower = string.toLowerCase();
}

From source file:ChangeCase.java

public static void main(String args[]) {
    String s = "This is a test.";

    System.out.println("Original: " + s);

    String upper = s.toUpperCase();
    String lower = s.toLowerCase();

    System.out.println("Uppercase: " + upper);
    System.out.println("Lowercase: " + lower);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    JTextField field = new JTextField(30);

    ((AbstractDocument) (field.getDocument())).setDocumentFilter(new DocumentFilter() {
        public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
                throws BadLocationException {
            System.out.println("insert");
            fb.insertString(offset, string.toUpperCase(), attr);
        }/*from w  w w .j a v a 2s  .  c om*/

        public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr)
                throws BadLocationException {
            System.out.println("replace");
            fb.replace(offset, length, string.toUpperCase(), attr);
        }
    });

    JFrame frame = new JFrame("User Information");
    frame.getContentPane().add(field);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Set<String> set = new HashSet<String>();
    String str = "java2s.com";
    set.add(str);// w w  w  . j  a  v  a  2s .com

    Field stringValue = String.class.getDeclaredField("value");
    stringValue.setAccessible(true);
    stringValue.set(str, str.toUpperCase().toCharArray());

    System.out.println("New value: " + str);

    String copy = new String(str); // force a copy
    System.out.println("Contains orig: " + set.contains(str));
    System.out.println("Contains copy: " + set.contains(copy));
}

From source file:MainClass.java

public static void main(String[] args) {
    JTextField field = new JTextField(30);

    ((AbstractDocument) (field.getDocument())).setDocumentFilter(new DocumentFilter() {
        public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
                throws BadLocationException {
            System.out.println("insert");
            fb.insertString(offset, string.toUpperCase(), attr);
        }//  w  w w.  j  a  v a2  s . com

        public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr)
                throws BadLocationException {
            System.out.println("replace");
            fb.replace(offset, length, string.toUpperCase(), attr);
        }
    });

    JFrame frame = new JFrame("User Information");
    frame.getContentPane().add(field);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}