提交 ec6d2a8e 编写于 作者: E Eric Riese

execute around lambda

上级 038befea
......@@ -22,7 +22,6 @@
*/
package com.iluwatar.execute.around;
import java.io.FileWriter;
import java.io.IOException;
/**
......@@ -42,14 +41,11 @@ public class App {
*/
public static void main(String[] args) throws IOException {
new SimpleFileWriter("testfile.txt", new FileWriterAction() {
@Override
public void writeFile(FileWriter writer) throws IOException {
writer.write("Hello");
writer.append(" ");
writer.append("there!");
}
});
FileWriterAction writeHello = writer -> {
writer.write("Hello");
writer.append(" ");
writer.append("there!");
};
new SimpleFileWriter("testfile.txt", writeHello);
}
}
......@@ -30,6 +30,7 @@ import java.io.IOException;
* Interface for specifying what to do with the file resource.
*
*/
@FunctionalInterface
public interface FileWriterAction {
void writeFile(FileWriter writer) throws IOException;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册