Created
January 11, 2024 12:31
-
-
Save oofnivek/e42c064c305c57a5c55f59c07b6e1bb1 to your computer and use it in GitHub Desktop.
Write string contents to file
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
package org.example; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class Main { | |
public static void main(String[] args) { | |
String content = "hello world"; | |
try { | |
Files.write(Paths.get("output.txt"), content.getBytes()); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment