배열의 정수를 다른 줄로 구분 된 텍스트 파일로 출력하는 방법을 알고 싶습니다. 아래의 관련 코드는 있지만 프로그램을 실행할 때마다 파일이 만들어 지지만 파일 자체에 데이터가 저장되지 않습니다.배열의 내용을 Java의 텍스트 파일로 출력하는 방법은 무엇입니까?
public static void printToFile(double[] gravity)throws IOException
{
PrintWriter outputFile = new PrintWriter (new FileWriter("gravitydata.txt", true));
for(int a = 0; a < 9; a++)
{
outputFile.println(gravity[a]);
}
}
당신은'outputFile.close();를 호출하는 것을 잊어 버린다. –
맞다 - 나에게 이길 수있어! –