execute around lambda
This commit is contained in:
parent
038befea26
commit
ec6d2a8ebe
@ -22,7 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.execute.around;
|
package com.iluwatar.execute.around;
|
||||||
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,14 +41,11 @@ public class App {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
new SimpleFileWriter("testfile.txt", new FileWriterAction() {
|
FileWriterAction writeHello = writer -> {
|
||||||
|
writer.write("Hello");
|
||||||
@Override
|
writer.append(" ");
|
||||||
public void writeFile(FileWriter writer) throws IOException {
|
writer.append("there!");
|
||||||
writer.write("Hello");
|
};
|
||||||
writer.append(" ");
|
new SimpleFileWriter("testfile.txt", writeHello);
|
||||||
writer.append("there!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.io.IOException;
|
|||||||
* Interface for specifying what to do with the file resource.
|
* Interface for specifying what to do with the file resource.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface FileWriterAction {
|
public interface FileWriterAction {
|
||||||
|
|
||||||
void writeFile(FileWriter writer) throws IOException;
|
void writeFile(FileWriter writer) throws IOException;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user