Format strings into table : String Format « Data Type « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » Data Type » String Format 
2. 30. 2. Format strings into table
public class Main {
  public static void main(String args[]) {
    String format = "|%1$-10s|%2$-10s|%3$-20s|\n";
    System.out.format(format, "A""AA""AAA");
    System.out.format(format, "B""""BBBBB");
    System.out.format(format, "C""CCCCC""CCCCCCCC");

    String ex[] "E""EEEEEEEEEE""E" };

    System.out.format(String.format(format, (Object[]) ex));
  }
}
/*
|A         |AA        |AAA                 |
|B         |          |BBBBB               |
|C         |CCCCC     |CCCCCCCC            |
|E         |EEEEEEEEEE|E                   |
*/
2. 30. String Format
2. 30. 1. Format Calendar with String.format()
2. 30. 2. Format strings into table
2. 30. 3. String.format(): right pad a string
2. 30. 4. String.format(): left pad a string
2. 30. 5. Format a String (JDK1.5)
2. 30. 6. Pass value array to String.format()
2. 30. 7. Remove/collapse multiple newline characters.
2. 30. 8. Abbreviate string
2. 30. 9. Capital and uncapital strings
2. 30. 10. Transforms words to singular, plural, humanized (human readable), underscore, camel case, or ordinal form
2. 30. 11. Replace New Lines
2. 30. 12. Fix Line Separator
2. 30. 13. Abbreviates a String using ellipses in both sides.
2. 30. 14. Abbreviates a String using ellipses.
2. 30. 15. Capitalize the first character of the given string
2. 30. 16. Centers a String in a larger String of size size using the space character (' ').
2. 30. 17. Centers a String in a larger String of size size. Uses a supplied String as the value to pad the String with.
2. 30. 18. Centers a String in a larger String of size size. Uses a supplied character as the value to pad the String with.
2. 30. 19. Convert string to uppercase
2. 30. 20. Left pad a String with a specified String.
2. 30. 21. Left pad a String with a specified character.
2. 30. 22. Left pad a String with spaces (' ').
2. 30. 23. Makes the first letter caps and the rest lowercase.
2. 30. 24. Put quotes around the given String if necessary.
2. 30. 25. Quote a string so that it can be used as an identifier or a string literal in SQL statements.
2. 30. 26. Right pad a String with a specified String.
2. 30. 27. Right pad a String with a specified character.
2. 30. 28. Right pad a String with spaces (' ').
2. 30. 29. Trim off trailing blanks but not leading blanks
2. 30. 30. Truncate a String to the given length with no warnings or error raised if it is bigger.
2. 30. 31. Uncapitalizes a String changing the first letter to title case as per Character.toLowerCase(char). No other letters are changed.
2. 30. 32. Repeat String
2. 30. 33. Repeat a String repeat times to form a new String.
2. 30. 34. Strip Line Breaks
2. 30. 35. Trim any of the characters
2. 30. 36. Removes one newline from end of a String if it's there, otherwise leave it alone.
2. 30. 37. Removes newline, carriage return and tab characters from a string
2. 30. 38. Remove the leading and trailing quotes from str.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.