/** * @param path 读取文件路径 * @return */ public static String readFile(String path) { //获取文件路径 InputStream input = null; try { input = new FileInputStream(path); } catch (FileNotFoundException e) { e.printStackTrace(); } //设置字节 byte[] buffer = new byte[1024]; int n; //循环输入 String jar = null; StringBuffer stringBuffer = new StringBuffer(); while (true) { try { if (!((n = input.read(buffer)) != -1)) break; } catch (IOException e) { e.printStackTrace(); } //最后的值 String rs1 = new String(buffer); stringBuffer.append(rs1); } //关流 try { input.close(); } catch (IOException e) { e.printStackTrace(); } return stringBuffer.toString(); }
读取文件路径
最新推荐文章于 2024-08-02 17:18:41 发布