上机试题告急

B2(2分,读写文件各1分) 完成下面文件操作的练习
public class Test
{

public static void main(String[] asdfasdfas) throws Exception
{
    File f = new File("d:/test.txt");
    createFile(f);
    readFile(f);
}
public static void readFile(File f)
{// 读出文件f的内容,并打印出
}
public static void createFile(File f)
{// 向文件f中写入三行任意的字符串     
}

}

[code="java"]
public class Test
{

public static void main(String[] asdfasdfas) throws Exception
{
File f = new File("d:/test.txt");
createFile(f);
readFile(f);
}
public static void readFile(File f)
{// 读出文件f的内容,并打印出
Reader r = new FileReader(f);
BufferedReader br = new BufferedReader(r);
String str = null;
while((str = br.readLine())!=null)
{
System.out.println(str);
}
br.close();
r.close();
}
public static void createFile(File f)
{// 向文件f中写入三行任意的字符串
String str = "abc";
OuputStream os = new FileOutputStream(f);
os.write(str.getBytes());
os.flush();
os.close();
}
}
[/code]