So the target respone I suppose to get was something like this:
Sudoku - pwon071
-----------------------
| - - - | -1 9 | - 4 8 |
| - - - | 2 3 8 | 6 - - |
| 9 - 8 | - 6 - | 1 - 2 |
-----------------------
| - - 1 | - 7 - | 2 6 - |
| 3 - 2 | - - - | - - - |
| 7 - 9 | 8 - 4 | 5 - - |
-----------------------
| 2 7 3 | - 4 1 | - - 5 |
| - 8 - | 9 5 - | - 3 - |
| 5 - - | 7 - 3 | - 2 - |
-----------------------
But the actual respone I got was:
Sudoku - pwon071 ----------------------- | - - - | - 1 9 | - 4 8 | | - - - | 2 3 8 | 6 - - | | 9 - 8 | - 6 - | 1 - 2 | -----------------------| - - 1 | - 7 - | 2 6 - | | 3 - 2 | - - - | - - - | | 7 - 9 | 8 - 4 | 5 - - | -----------------------| 2 7 3 | - 4 1 | - - 5 | | - 8 - | 9 5 - | - 3 - | | 5 - - | 7 - 3 | - 2 - | -----------------------
I don't really know what went wrong! Supposingly t should work. So I hop someone can give me an answer. Thanks!
[/b] private void saveSudokuToFile() {
FileWriter fw = null;
writeSudokuToFile(fw);
----------------------------------------(another method)----------------------------------------------------------------------
private void writeSudokuToFile(PrintWriter fw) {
String fileName = fileNameT.getText();
int i,j;
if (fileName.length() <= 0) {
fileName = DEFAULT_FILE_NAME;
fileNameT.setText("" + DEFAULT_FILE_NAME);
}
currentGridOfValues = getGridOfValues(numberFields);
try {
fw = new FileWriter (fileName + ".txt");
fw.write("Sudoku - pwon071\n\n ----------------------- \n| ");
for (i=0;i<9;i++){
for(j=0;j<9;j++){
if(currentGridOfValues[i][j] != 0){
fw.write(currentGridOfValues[i][j] + " ");
}else{
fw.write("- ");
}
if ((j==2)||(j==5)){
fw.write("| ");
}else if(j==8){
fw.write("| \n");
}
}
if ((i==2)||(i==5)||(i==8)){
fw.write(" -----------------------\n");
}
if (i!=8){
fw.write("| ");
}
}
fw.close();
}catch(IOException e){
System.out.println(e);
}
}
[b]

New Topic/Question
Reply




MultiQuote






|