如何仅针对java的UVA联机问题获取字符串输入?所需的详细信息
我正在尝试使用JAVA为UVA在线判断问题输入字符串 像C++如何仅针对java的UVA联机问题获取字符串输入?所需的详细信息,java,arrays,user-input,readline,eof,Java,Arrays,User Input,Readline,Eof,我正在尝试使用JAVA为UVA在线判断问题输入字符串 像C++ while(s = getchar()) { if(s == EOF) } 这就是你要找的吗?如果您正在从文件中读取 import java.io.File; Scanner scanner = new Scanner(new File("path.txt")); while (scanner.hasNextLine()) { String str = scanner.nextLine();
while(s = getchar()) {
if(s == EOF)
}
这就是你要找的吗?如果您正在从文件中读取
import java.io.File;
Scanner scanner = new Scanner(new File("path.txt"));
while (scanner.hasNextLine()) {
String str = scanner.nextLine();
//...
}
我使用以下方法解决了这个问题
Scanner stdin = new Scanner(System.in);
while (stdin.hasNextLine())
{
String line = stdin.nextLine();
// Further Opera
}
Scanner stdin = new Scanner(System.in);
while (stdin.hasNextLine())
{
String line = stdin.nextLine();
// Further Opera
}