Created
June 29, 2017 13:58
-
-
Save miho/6f9b6678ce18e713783ba6c72c7c15fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.Files; | |
@ComponentInfo(name="SaveStringToFile", category="Custom") | |
public class SaveStringToFile implements java.io.Serializable { | |
private static final long serialVersionUID=1L; | |
// add your code here | |
public void saveStringTheJavaWay(String s, @ParamInfo(name="", style="save-dialog", options="") File f) { | |
Files.write(f.toPath(), s.getBytes()) // overwrite file if it exists | |
} | |
public void saveStringTheGroovyWay(String s, @ParamInfo(name="", style="save-dialog", options="") File f) { | |
f.delete() // delete file | |
f << s // add context to file | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment