输入文件中的引号不返回任何标记

时间:2014-05-06 06:20:04

标签: java java.util.scanner quotes

import java.util.Scanner;
import java.io.*;

public class TESTEEZ
{
  public static void main(String[] args) 
   throws FileNotFoundException
  {
   Scanner test = new Scanner(new File("untitled text.txt"));
   tester(test);
  }

  public static void tester(Scanner tested)
  {
   int count = 0;

   while(tested.hasNext())
   {
    //does nothing; used to keep the input cursor in the correct spot in a different
    //project, put it here on the off chance that was my issue
    String string = tested.next();
    count++;
   }

   System.out.println(count);
  }
}

返回untitled text.txt中有多少令牌,这只是一个非常基本的事情。但是,每当我引用""标记时,它总是为零;无论出于何种原因,tested.hasNext()似乎都是假的。我只是好奇我错过/忽视的超级明显的东西。我没有在无标题的text.txt中使用引号尝试过它,它运行正常。

这是无标题的text.txt:

Hello there,how are you?
I am "very well", thank you.
12 34 5.67 (8 + 9) "10"

0 个答案:

没有答案