Example usage for java.util Formatter Formatter

List of usage examples for java.util Formatter Formatter

Introduction

In this page you can find the example usage for java.util Formatter Formatter.

Prototype

public Formatter() 

Source Link

Document

Constructs a new formatter.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%.15s", "Formatting with Java is now easy.");
    System.out.println(fmt);/*from  w  ww .j av  a2 s. c  o  m*/
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("Hex: %x, Octal: %o", 196, 196);
    System.out.println(fmt);//  ww w .  ja v  a 2s. co m
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%.4f", 123.1234567);
    System.out.println(fmt);//from w w  w. j a  va 2  s . c o  m
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("|%-10.2f|", 123.123);
    System.out.println(fmt);//from w  w w.jav  a  2s. c  om
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("Copying file%nTransfer is %d%% complete", 88);
    System.out.println(fmt);/*  w w w.j av a 2  s  .c  om*/
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%a", 123.123);
    System.out.println(fmt);/* w  w w.j av a  2s. c  om*/
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("Formatting %s is easy %d %f", "with Java", 10, 98.6);

    System.out.println(fmt.toString());
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%05d", 88);
    System.out.println(fmt);//w  w  w. j av a2s  .  com
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("|%10.2f|", 123.123);
    System.out.println(fmt);/*from ww  w .  j a  v  a  2  s. c  o  m*/
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%3$d %1$d %2$d", 10, 20, 30);

    System.out.println(fmt);//from   w w  w  .  j  a va 2 s .c  o  m
}