62,621
社区成员
发帖
与我相关
我的任务
分享
public String func() {
InputStream is = System.in; // 指向键盘
InputStreamReader isr = new InputStreamReader(is);
reader = new BufferedReader(isr);
String line = null;
line = reader.readLine();
return line
}
public String parseMagcard(Charset charset) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
long startTime = System.currentTimeMillis();
String line = null;
try {
while ((System.currentTimeMillis() - startTime) < time * 1000
&& !in.ready()) {
}
if (in.ready()) {
line = in.readLine();
} else {
// System.out.println("You did not enter data");
line = "-1";
}
} catch (IOException e) {
e.printStackTrace();
}
return line;
}
public class Test2 {
static String a;
public static void main(String[] args) throws InterruptedException {
T t = new T();
t.setDaemon(true);
t.start();
System.out.print("等待用户输入:");
Thread.sleep(3000);
if(a==null){
System.out.println("no");
}else{
System.out.println(a);
}
System.out.println("over");
}
}
class T extends Thread{
@Override
public void run() {
Test2.a = new Scanner(System.in).nextLine();
}
}