Results 1 to 5 of 5
- 04-24-2008, 01:09 PM #1
Member
- Join Date
- Apr 2008
- Posts
- 13
- Rep Power
- 0
- 04-24-2008, 01:34 PM #2
Hello Pooja,
Using Console API( In Java 6) to output formatted content is much easy.
You can call : console.format(String fmt, Object... args)
OR
console.printf(String fmt, Object... args) to print formatted data
And The main method for handling user-input : readLine().
This method ( readLine(String fmt, Object... args) ) is a combination of formatted output with user input. The method uses the java.util.Formatter syntax for the first argument, and applies the results of the args array.
Example:
If any doubt please let me know.Java Code:import java.io.*; public class ConsoleExample { public static void main(String[] args){ Console console = System.console(); if(console != null) { String formatString = "%1$4s %2$5s %3$10s%n"; String name = console.readLine(formatString,"Please","Enter","Your Name :"); } } }
sanjeev,संजीव
- 04-24-2008, 04:46 PM #3
Hi Pooja,
You can also see the Console API in action in my small tutorial at:
Console applications with Java 6 | Little Tutorials
EnjoyDaniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 04-25-2008, 05:49 AM #4
Member
- Join Date
- Apr 2008
- Posts
- 13
- Rep Power
- 0
Hi All,
thank you for your prompt response!
my doubt got cleared!:):)
- 04-25-2008, 05:51 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ok Pooja, nice to hear that. So please mark the thread solved. :)
Similar Threads
-
How to create object dynamically with class name known in string format
By ranu_gokhe in forum Advanced JavaReplies: 1Last Post: 04-09-2008, 02:15 AM -
Java Swing class capturing output to the console
By Java Tip in forum Java TipReplies: 0Last Post: 03-12-2008, 11:24 AM -
Reading a line from console using Scanner class
By Java Tip in forum Java TipReplies: 0Last Post: 01-18-2008, 11:52 AM -
Read from console (Scanner Class)
By hey in forum New To JavaReplies: 10Last Post: 12-11-2007, 10:11 PM -
Creating object of Type Object class
By venkatv in forum New To JavaReplies: 3Last Post: 07-17-2007, 03:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks