I have this piece of code that is suppose to read in a file and count how many lines it has, number of words, etc... but for some reason it is not reading this file in for some reason
http://faculty.utpa.edu/rtschweller/...dictionary.txt
I can put in other inputs and other words, as a matter of fact, I can put what I want and it will read the file properly and do everything i ask it to. I can even give it huge files that take my computer a while to compute and it will still work but once I give it this file, it will not read it at all. I can erase all of it's input and put something else in this file it will read it but I give it the input in the file it won't read it. I even cut this file in half a few times until i gave it a tiny input and it started reading it. I copied it over millions of times and it read it, I give it back this file's input again, it won't even attempt to read it.
Any suggestions?
HTML Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package dictionary;
import java.util.*;
import java.io.*;
/**
*
* @author Marlin
*/
public class Driver {
public static void main(String [] args)
{
//open input and output files
File input, output;
input = new File("data.txt");
output = new File("pigReport.txt");
//create a report based on input file, written to output file
createReport(input, output);
}
public static void createReport(File input, File output)
{
try
{
//create buffered reader and writer objects
Scanner reader = new Scanner(input);
BufferedWriter writer = new BufferedWriter( new FileWriter(output) );
//declare some counter variables
int linecount=0;
int wordcount=0;
int charcount=0;
boolean workappropriate=true;
//read each line from input file one by one...
while( reader.hasNextLine() )
{
//increment line count
linecount++;
//get that line from the file
String theline = reader.nextLine();
//increment wordcount by number of words in line
wordcount += countWords(theline);
//increment char count by chars in line
charcount += theline.length();
//check for swear words
if( theline.toLowerCase().contains("frack") )
workappropriate = false;
}
//write statistics to output file
writer.write("The report:\n");
writer.write("Number of lines: " + linecount + "\n");
writer.write("Number of words: " + wordcount + "\n");
if( workappropriate )
writer.write("This is ok for work");
else
writer.write("Only when boss is not looking...");
writer.close();
}
catch(Exception e)
{
System.out.println("File problem...");
}
}
//return number of words in s
public static int countWords(String s)
{
String [] words;
words = s.split(" ");
return words.length;
}
}