i create a matrix of integers inside a file using this,and i want to overwrite a value after creating it,this is the code:
import java.io.File;
import java.io.FileWriter;
public class main {
public static void main(String[] args) {
File file = new File("foo/file.txt");
FileWriter writer = null;
try {
file.createNewFile();
writer = new FileWriter(file);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
writer.write(String.valueOf(0) + " ");
}
writer.write("\n");
}
} catch (Exception e) {
e.printStackTrace();
}
try {
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (i == 3)
writer.write(String.valueOf(1) + " ");
}
}
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
any suggestions? thanks.