Skip to content

Instantly share code, notes, and snippets.

@miho
Created June 29, 2017 13:58
Show Gist options
  • Save miho/6f9b6678ce18e713783ba6c72c7c15fd to your computer and use it in GitHub Desktop.
Save miho/6f9b6678ce18e713783ba6c72c7c15fd to your computer and use it in GitHub Desktop.
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