I have a little problem in file writing in Java.
I've created a new file using File f = new File(path);
and
a BufferedWriter
that writes to that file. And one int i = 1;
Now the buffered writer (file writer) shall write the int i to the file
but it doesn't, It writes CUBES! Like this one ■.
And When Scanner reads the file, it reads that cube, and an error happens,
Here is an example:
int i = 1;
File f = new File(path);
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
bw.write(i);
int b = 0;
Scanner s = new Scanner(new FileReader(f));
b = s.nextInt();
//end
But for some reason it writes a cube ■ not number 1, and that's why scanner cant read it.
Any ideas why is this happening? -Thank for helping. ■