I have a text file called test.txt with the word hello. I am trying to read it using Reader.read() method and print the contents to console. However when I run it I am just getting the number 104 printed on console and nothing else (I get the same number printed even if I change the text to more/less characters). Any ideas why it is behaving this way and how can I modify this existing code to print the contents of test.txt as a string on console? Here is my code:
public static void spellCheck(Reader r) throws IOException{
Reader newReader = r;
System.out.println(newReader.read());
}
and my main method I am using to test the above:
public static void main (String[] args)throws IOException{
Reader test = new BufferedReader(new FileReader("test.txt"));
spellCheck(test);
}