Skip to content

Instantly share code, notes, and snippets.

@walidum
Created May 23, 2021 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walidum/0397f2204793ead2a5b987878144adeb to your computer and use it in GitHub Desktop.
Save walidum/0397f2204793ead2a5b987878144adeb to your computer and use it in GitHub Desktop.
New File Methods
//Demo.java
public static String newFileMethods() {
String home = System.getProperty("user.home");
Path filePath = Paths.get(home, "test.txt");
try {
Files.writeString(filePath, "Hello World !!");
return Files.readString(filePath);
} catch (IOException e) {
return "";
}
}
//DemoTest.java
@Test
public void newFileMethodsTest() {
assertTrue(Demo.newFileMethods().equals("Hello World !!"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment