Answers for "how to load string from file in java"

1

load file as string java

public static String loadFileAsString(String path) {
  InputStream stream = YourClassName.class.getResourceAsStream(path);
  try {
    String result = new String(stream.readAllBytes());
    return result;
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
}
Posted by: Guest on July-06-2021

Code answers related to "how to load string from file in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language