商务合作:179001057@qq.com

java读取远程文件

技术2022-05-11  0


某平台价值19860元的编程课程资料免费领取【点我领取】


package read; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; public class Test extends Thread {     String str = "";     public void run() {         while (true) {             File file = new File("//192.168.1.110/hhh/abc.txt");             int size = (int) file.length();                 try {                     FileReader readIn = new FileReader(file);                     BufferedReader br = new BufferedReader(readIn);                     String strtemp = null;                     while ((strtemp = br.readLine()) != null) {                         str  = str + strtemp;                         //System.out.println(str);                     }                     br.close();                     readIn.close();                     this.sleep(5000);                 } catch (Exception e) {                     e.printStackTrace();                 }              if (new File("//192.168.1.110/hhh/abc.txt").length() != size) {                  System.out.println(str);             } else {                 System.out.println("-------------File no change-------------");             }         }     } }

最新回复(0)