我在维基百科中读到,Decorator模式用于.Net和Java IO类.
任何人都能解释一下这是如何使用的吗?它有一个可能的例子,它有什么好处?
维基百科上有一个Windows窗体的例子,但我想知道Java IO类是如何发生的.
我有以下代码
try
{
FileWriter fileWriter = new FileWriter("C:\\temp\\test.txt");
fileWriter.write("Hi this is sasi This test writing");
fileWriter.append("test");
}
catch(IOException ioException)
{
ioException.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
执行后,文件创建成功,但创建的文件为空
那么代码有什么问题?