[size=“18”]Alguém tem a classe Console ? Caso alguém tenha manda aí
Ficaria Bastante Grato[/size]
[size=“18”]Alguém tem a classe Console ? Caso alguém tenha manda aí
Ficaria Bastante Grato[/size]
desculpe a ignorancia, mas o que é classe console??? :oops:
desculpe a ignorância também, mas será que não está confundindo as coisas não? Nunca ouvi falar de classe console.
Será que não é pra tu executar suas tarefas via console não? (Dos) Telinha preta com letras brancas!
Brincadeiras a parte, é bom até saber se não for isso o que é !
:lol:
Ô amigão, eu não tenho a Classe Console em si mas tenho a Util e a Keyboard, se vc quiser manda uma pvt com seu e-mail que lhe envio, as duas fazem as mesmas coisas que a Console.
E para a galerinha que não conhece, a classe Console ou essas duas que citei serve para ler do teclado, para não usar as classes BufferedReader e a Input. Se bem que no Tiger existe o Scanner, mas ele deve tar na faculdade usando o Java 1.4.3.
[]s pessoal…
La vai!
/**
An easy interface to read numbers and strings from
standard input
@version 1.10 10 Mar 1997
@author Cay Horstmann
*/
public class Console
{ /**
print a prompt on the console but don't print a newline
@param prompt the prompt string to display
*/
public static void printPrompt(String prompt)
{ System.out.print(prompt + " ");
System.out.flush();
}
/**
read a string from the console. The string is
terminated by a newline
@return the input string (without the newline)
*/
public static String readLine()
{ int ch;
String r = "";
boolean done = false;
while (!done)
{ try
{ ch = System.in.read();
if (ch < 0 || (char)ch == '\n')
done = true;
else if ((char)ch != '\r') // weird--it used to do \r\n translation
r = r + (char) ch;
}
catch(java.io.IOException e)
{ done = true;
}
}
return r;
}
/**
read a string from the console. The string is
terminated by a newline
@param prompt the prompt string to display
@return the input string (without the newline)
*/
public static String readLine(String prompt)
{ printPrompt(prompt);
return readLine();
}
/**
read an integer from the console. The input is
terminated by a newline
@param prompt the prompt string to display
@return the input value as an int
@exception NumberFormatException if bad input
*/
public static int readInt(String prompt)
{ while(true)
{ printPrompt(prompt);
try
{ return Integer.valueOf
(readLine().trim()).intValue();
} catch(NumberFormatException e)
{ System.out.println
("Not an integer. Please try again!");
}
}
}
/**
read a floating point number from the console.
The input is terminated by a newline
@param prompt the prompt string to display
@return the input value as a double
@exception NumberFormatException if bad input
*/
public static double readDouble(String prompt)
{ while(true)
{ printPrompt(prompt);
try
{ return Double.parseDouble(readLine().trim());
} catch(NumberFormatException e)
{ System.out.println
("Not a floating point number. Please try again!");
}
}
}
}