Java 7+: Writing A String To File--A One Liner 📎
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class StringToFile {
public static void main(String[] args) throws IOException {
String msg = "hello";
Files.write(Paths.get("./duke.txt"), msg.getBytes());
}
}
There are probably programming languages out there which achieve the same with fewer characters. In Java, however, we have IDEs :-).
See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!