📜  将文件加载为字符串 java 代码示例

📅  最后修改于: 2022-03-11 14:52:49.302000             🧑  作者: Mango

代码示例2
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;
  }
}