怎么通过FileWriter向文件写里东西

第一次提问,不知道问题能不能说明白

我的代码如下 能运行 也未抛异常 就是没写到文件里

package hhh;

import java.io.FileWriter;

import java.io.IOException;

public class write {
public static void main(String[] a) {

    FileWriter out = null;
    try {
        out = new FileWriter("F:/sh.txt");
        out.write("孙洪超1987");
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}

}

在你的write完,记得[code="java"]writer.close();[/code]

对 流这个东西用完了一定要关闭 加上楼上说的话 就行了

[color=indigo]应该是没有加到缓存中吧,flush();[/color]