/** * 读取txt文本中内容 */ public static void getTxt(){ File file = new File("C:\\Users\\73G9Y\\Desktop\\LNQ300.txt"); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String tempStr; hang = 0; while ((tempStr = reader.readLine()) != null) { if(hang > 0){ //按行打印txt中内容 System.out.println(tempStr); } hang++; } reader.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { e1.printStackTrace(); } } } }
读取txt文本中内容
最新推荐文章于 2024-05-16 10:23:10 发布