1、从文本中的读取 String path = "src/test/resources/getPhysicalPortsResponse.json"
public static String getFileFromPath(String path){ StringBuffer sb = new StringBuffer(); try { File file = new File(path); Reader reader = new InputStreamReader(new FileInputStream(file)); int ch=0; while ((ch = Objects.requireNonNull(reader).read()) != -1) { sb.append((char) ch); } reader.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); return null; } }