I want to know how can i read the contents of a file, character by character?
I tried this code
Scanner sc = new Scanner(new BufferedReader(newFileReader("C:\\saml.txt")));
while(sc.hasNext())
{
String s=sc.next();
char x[]=s.toCharArray();
for(int i=0;i<x.length;i++)
{
if(x[i]=='\n')
System.out.println("hello");
System.out.println(x[i];
}
I want to give input in file as: "pure world it is"
I want the output "pure hello world hello it hello is hello"