漂亮的自我解釋性標題。爲什麼我的程序不能將文本寫入.txt文件?代碼如下:爲什麼我的代碼會創建一個.txt文件,但不會在其中寫入信息?
package juego;
import java.io.*;
/**
*
* @author Administrador
*/
public class Archivo
{
public void crearArchivo()
{
try
{
FileWriter fw = new FileWriter("ReglasDelTablero.txt");
PrintWriter pw = new PrintWriter(fw);
pw.println("<7,0> , <0,0>");
pw.println("<4,1> , <7,2> | <2,7> , <5,5> | <1,2> , <7,4> | <0,4> , <2,5>");
pw.println("<7,7> , <3,6> | <6,4> , <3,5> | <4,0> , <2,1> | <2,4> , <0,3>");
}
catch(IOException e)
{
System.out.println("error");
}
}
}
可能的重複[Printwriter not writing to outputStream](http://stackoverflow.com/questions/8088219/printwriter-not-writing-to-outputstream) – Lutz