I have an 18,000 line text file that I am scanning from a mapped network drive. I am using the scanner class in Java. When the file is stored on my local machine, my code confirms that it has 18,000 lines via a line counter variable. Using the same code, but only changing the file path of the text file to the network drive, it returns ~700 lines. Does anyone know why this might be happening? When I drag the file from network drive to C, it returns 700, but when I copy the contents and put it in a new file in C drive, it returns the true number of lines. My code is below:
public static void main(String[] args) throws FileNotFoundException
{
File text = new File("C:\\Users\\textfile.txt"); //returns correct number of lines
//File text = new File("N:\\textfile.txt"); //returns incorrect number of lines
Scanner scan = new Scanner(text);
int linecount = 0;
while(scan.hasNextLine())
{
linecount++;
scan.nextLine();
}
scan.close();
System.out.println(linecount);
}