file reader returning null when file is not null content
hello,
any assistance would be largely appreciated.
File FileChecker=new File("/Users/Jason/
Desktop/ad_log.txt");
if (!FileChecker.exists()){
FileChecker.createNewFile();
}else{
//build existing records.
//Existing_Records=
getContents(FileChecker);
} //here i check if
the file exists. if it doesn't i make a new one. otherwise i want to
read my old one, using getContents.
//getContents:
static public void getContents(File args) throws Exception{
String[] TempLine;
Scanner freader = new Scanner(args);
//BufferedWriter writer = new BufferedWriter(new
FileWriter(toFile));
//... Loop as long as there are input lines.
String line = null;
while (freader.hasNextLine()) {
line = freader.nextLine();
System.out.println(line);
}
//... Close reader and writer.
freader.close(); // Close to unlock.
// Close to unlock and flush to disk.
}
for some reason that i cannot figure out this is returning null.
the file is definitely not null and contains very long strings.
the strings contain new line by using:
System.out.println("what i write to my file");
any help would be largely appreciated!