ReadLine(String fmt,Object... args) of Console class

Ads

 
 

Share on Google+Share on Google+

Pooja
ReadLine(String fmt,Object... args) of Console class
1 Answer(s)      9 years ago
Posted in : Java Beginners

How to reload the string and objects of console class in Java?

Ads
View Answers

April 25, 2008 at 7:30 PM


Hi friend,

import java.io.Console;
import java.io.PrintWriter;
import java.util.Scanner;

public class ConsoleExample{
public static void main(String[] args){

Console console = System.console();
if(console != null) {
String formatString = "%1$4s %2$10s %3$10s%n";
console.printf(formatString, "Idx", "A", "B");
console.printf(formatString, "1", "10", "100");
console.printf(formatString, "2", "20", "200");
console.printf(formatString, "3", "30", "300");
console.printf(formatString, "4", "40", "400");
console.printf(formatString, "5", "50", "500");
String name = console.readLine("Please Provide Your Name: =");
char[] passdata = console.readPassword("[Please Input Your Password]: ");
Scanner scanner = new Scanner(console.reader());
int in = 0;
while(in != 10){
console.printf("Please input a value between 0 and 9.");
in = scanner.nextInt();
}

PrintWriter out = console.writer();
System.out.println("Test regular writing!");
}
else{
System.out.println("Can't run w/out a console!");
}
}
}


Ads









Related Tutorials/Questions & Answers:
ReadLine(String fmt,Object... args) of Console class - Java Beginners
ReadLine(String fmt,Object... args) of Console class  How to reload the string and objects of console class in Java?  Hi friend,import... ConsoleExample{ public static void main(String[] args){ Console console
CONSOLE
of those objects, is a static publicly available object inside that class. The object... class. Standard output is, on most operating systems, console output. format...: It is a class made available by Java to let you manipulate various operating
Advertisements
readline Error - Java Beginners
not work. The readLine () method seems to loose the first character of the string... (String[] args) { boolean done=false; while (!done... ------------ class Advertisement extends Thread { private String message
readline Error 2 - Java Beginners
: import java.io.*; class TestAdvt{ public static void main (String[] args...readline Error 2  Hi sir, can you look again please. The error is hard to notice, but if you execute the code, 1. enter a string the first input
Version of rubygems>jruby-readline dependency
List of Version of rubygems>jruby-readline dependency
Input From Console
;  The Console Class inherits from Java.io.console... in understanding a code Input from Console. For this we have a class 'Input From Console... return you an console object and provides you unique console object
Reading Value From console
Reading Value From console  In case of String data Type readLine method of DataInputStream class read complete line of the given string but the next method of Scanner class doesn't read the complete line of String. why
Reading Value From console
Reading Value From console  In case of String data Type readLine method of DataInputStream class read complete line of the given string but the next method of Scanner class doesn't read the complete line of String. why
String Class implementation in API
String Class implementation in API  Hi all, I was confused ,when am looking into java String class single argument constructor into that we... we send String as argument for String class
String tokenizer class
String tokenizer class  Hai... What is string tokenizer class? & what's its purpose
String tokenizer class
String tokenizer class  Hai... What is string tokenizer class? & what's its purpose
String tokenizer class
String tokenizer class  Hai... What is string tokenizer class? & what's its purpose
Determine if string is in class
; } } public class CarsList { public static void main(String args... and a Car class. The string is the name of the car, which i have multiple in my linked.... import java.util.*; class Car { private String name; private int price
(ii) String and String Buffer Class
(ii) String and String Buffer Class  difference between String and String Buffer Class
(ii) String and String Buffer Class
String and String Buffer Class  differences between : String and String Buffer Class
(ii) String and String Buffer Class
between String and StringBuffer 1) String object is immutable...String and String Buffer Class  difference between String and String Buffer Class
Maven Dependency jruby-readline >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of rubygems >> jruby-readline version1.1.1 in your project
Maven Dependency jruby-readline >> 1.0
You should include the dependency code given in this page to add Maven Dependency of rubygems >> jruby-readline version1.0 in your project
Maven Dependency jruby-readline >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of rubygems >> jruby-readline version1.1.0 in your project
how to use string of one class into another Class
how to use string of one class into another Class  I created textField(JTextField t1=new JTextField();(it is in ClassA. The input of this textField i.e t1.getText() is to be used in different(another Class say in ClassB. How can
java class string - Java Beginners
(String [] args) throws IOException{ try{ BufferedReader br = new...java class string  Write a program that reads three strings; then appends to the first string the string formed when extracting from the second
Need help with console program?
java.io.*; class Input { public static void main(String[] args) throws...Need help with console program?  Write a console program...(System.in)); System.out.print("Enter: "); String str=br.readLine
how to pass a string from one class to another
(String[] args) { Class1 class1 = new Class1(); // Creating object...how to pass a string from one class to another  hi all, Good morning. I am trying to develop a coding pass a string from one class and declare
Convert String to Class - JSP-Servlet
. Reading job name, class name, day & time using xml file only. Problem is while reading class name, retrieve as a string format but Quartz required in "Class" format...Convert String to Class  Hi all, I am using Quartz as a scheduler
String Class in Action Script3
.style1 { font-size: medium; } String Class in Action Script3:- String class is a data type. String class provides methods for access... types of String class objects. String class have different types of constructors
Invalid console appender in JBoss console
Invalid console appender in JBoss console  "ERROR: invalid console appender config detected, console stream is looping" The above is the error i am getting while starting the server after deploying the ear file into the jboss. I
c++ new, delete, string class
c++ new, delete, string class  Write one program containing all these string exercises. Read a string from the user into a string named string1... contained in string1: Exercise 1 Good morning Create a new string named string2
Date Class with Single String parameter constructor example
.style1 { font-size: medium; } Date class with single string parameters to the Date() constructor example:- The Date class have a single string parameterized constructor. If user pass a string parameter in the date class
Writing code with multiple Class Methods and String Arrays
Writing code with multiple Class Methods and String Arrays  So what I... input. It has to have multiple classes so I will have a main class, and a class... In these classes I need to create string arrays that contain artist names, and be able
Writing code with multiple Class Methods and String Arrays
Writing code with multiple Class Methods and String Arrays  So what I... input. It has to have multiple classes so I will have a main class, and a class... In these classes I need to create string arrays that contain artist names, and be able
Redirecting the console output into a file in Java
*; public class ReadSpecificLine { public static void main(String[] args...(String[] args) throws IOException { BufferedReader in = new BufferedReader...Redirecting the console output into a file in Java  Hi, i coded

Ads

 
Advertisement null

Ads