任何人都可以解释我的类之间的区别BufferedReader,FileReader以及Scanner?当我想阅读文本文件时使用哪一个?
我试图检查用户给出的单词是否已经存在于文本文件中,或者它的子字符串是否已存在.这是我的代码:
String ans = null;
Scanner scanner = null;
do
{
System.out.print("Please enter a new word: ");
String Nword = scan.next();
System.out.print("And its appropriate Hint: ");
String Nhint = scan.next();
Word word = new Word(Nword , Nhint);
File file = new File("C:\\Users\\Charbel\\Desktop\\Dictionary.txt");
file.createNewFile();
scanner = new Scanner(file);
if (scanner != null)
{
String line;
while (scanner.hasNext()) {
line = scanner.next();
for(int i = 0 ; i<line.length(); i++)
if ((line.equals(Nword)) || (Nword.equals(line.substring(i))))
{
System.out.println("The word already exists.");
break;
}
}
} …Run Code Online (Sandbox Code Playgroud) 同道编码员,我只想知道是否有一个HTML代码可以将我链接到另一个html/php页面的中间,而不是在同一页面上.我搜索了很多网站,但我找到的所有网站都链接到同一页面的中间位置.希望有人可以帮助我