本文整理了Java中java.io.Console.reader()
方法的一些代码示例,展示了Console.reader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Console.reader()
方法的具体详情如下:
包路径:java.io.Console
类名称:Console
方法名:reader
[英]Returns the Reader associated with this console.
[中]返回与此控制台关联的读取器。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Reader reader() {
return delegate.reader();
}
代码示例来源:origin: apache/nifi
@Override
public Reader reader() throws ConsoleException {
return console.reader();
}
代码示例来源:origin: stackoverflow.com
BufferedReader in = new BufferedReader(System.console().reader());
BufferedWriter out = new PrintWriter(System.console().writer(), true);
out.println(in.readLine().toUpperCase());
代码示例来源:origin: org.smartdeveloperhub.harvesters.ci.util/ci-util-console
/**
* {@inheritDoc}
*/
@Override
public Reader reader() {
return this.console.reader();
}
代码示例来源:origin: com.b2international.snowowl/com.b2international.commons.base
@Override
public Reader reader() {
return console.reader();
}
代码示例来源:origin: anba/es6draft
@Override
public Reader reader() {
return console.reader();
}
代码示例来源:origin: stackoverflow.com
Console cons = System.console();
if(cons != null) {
char c = (char) cons.reader().read(); // Checking for EOF omitted
...
}
代码示例来源:origin: stackoverflow.com
Console console = System.console(); // 16
Reader reader = console.reader(); // 17
代码示例来源:origin: org.openksavi.sponge/sponge-core
@Override
public void open() {
console = System.console();
reader = console != null ? new BufferedReader(console.reader()) : new BufferedReader(new InputStreamReader(System.in));
}
代码示例来源:origin: stackoverflow.com
Console cons = System.console();
if (cons != null) {
System.out.println("Enter single character: ");
char c = (char) cons.reader().read();
System.out.println(c);
}else{
System.out.println(cons);
}
代码示例来源:origin: stackoverflow.com
Console console = System.console();
if (console != null) {
Scanner scanner = new Scanner(console.reader());
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
// Do something with your line
}
}
代码示例来源:origin: stackoverflow.com
Pattern pattern = Pattern.compile(
"[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)");
try(BufferedReader br=new BufferedReader(System.console().reader())) {
br.lines()
.flatMap(line -> StreamSupport.stream(new MatchItr(pattern.matcher(line)), false))
.collect(Collectors.groupingBy(o->o, TreeMap::new, Collectors.counting()))
.forEach((k, v) -> System.out.printf("%s\t%s\n",k,v));
}
代码示例来源:origin: stackoverflow.com
Scanner fi = new Scanner(System.console().reader());
System.out.println(fi.nextInt());
fi.close();
fi = new Scanner(System.console().reader());
System.out.println(fi.nextInt());
fi.close();
代码示例来源:origin: stackoverflow.com
public class Example {
public Example() {
Scanner scanner = new Scanner(System.console().reader());
// note change on above line
int row = scanner.nextInt();
scanner.close();
}
}
代码示例来源:origin: stackoverflow.com
import java.io.*;
public class KeyTest2 {
public static void main(String[] argv) {
try {
Console cons = System.console();
if (cons != null) {
Reader unbuffered = cons.reader();
for (int i = 0; i < 10; ++i ) {
int x = unbuffered.read();
System.out.println(String.format("%08x", x));
}
}
} catch (Exception e) {
System.err.println(e);
}
}
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args){
promptUserForInput();
}
public static int promptUserForInput(){
Scanner in = new Scanner(System.console().reader());
PrintWriter out = System.console().writer();
out.print("Enter an integer:");
// [...]
}
代码示例来源:origin: stackoverflow.com
public static void main(String args[]) {
Console console = System.console();
BufferedReader reader = new BufferedReader(console.reader());
main2(reader, console.writer(), args);
}
static void main2(BufferedReader reader, Writer writer, String args[] {
String str = reader.readline();
System.out.println("halo"+str);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args){
promptUserForInput(System.console());
}
public static int promptUserForInput(Console io){
Scanner in = new Scanner(io.reader());
PrintWriter out = io.writer();
out.print("Enter an integer:");
// [...]
}
代码示例来源:origin: padreati/rapaio
public StandardPrinter() {
Console console = System.console();
if (console != null) {
reader = console.reader();
writer = console.writer();
} else {
reader = new InputStreamReader(System.in);
writer = new PrintWriter(System.out);
}
withTextWidth(190);
withGraphicShape(1280, 800);
}
代码示例来源:origin: org.apache.juneau/juneau-microservice-server
/**
* Constructor.
*
* @param args Command line arguments.
* @throws Exception
*/
protected Microservice(String...args) throws Exception {
setInstance(this);
Console c = System.console();
consoleReader = new Scanner(c == null ? new InputStreamReader(System.in) : c.reader());
consoleWriter = c == null ? new PrintWriter(System.out, true) : c.writer();
setArgs(new Args(args));
setManifest(this.getClass());
}
内容来源于网络,如有侵权,请联系作者删除!