Please see the Class file below called StringToFile. All I want to do is call a method inside StringToFile using another class file. Can anyone do this?
package StringToFile;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
public class StringToFile {
public static void main(String[] args) throws IOException {
}
public static void write() throws IOException {
String msg = "hello you\nthis is just a test\n";
Files.write(Paths.get("./duke.txt"), msg.getBytes());
}
public static void read() throws IOException {
List < String > lines = Files.readAllLines(Paths.get("./duke.txt"), Charset.defaultCharset());
for (String line: lines) {
System.out.println("line read: " + line);
}
}
}