Android 读写设备节点

2019-05-03  本文已影响0人  冻柠猹

定义节点路径:

static final String PATH = "/productinfo/.save_capacity";

写入节点:

try{
      BufferedWriter bufWriter = null;
      bufWriter = new BufferedWriter(new FileWriter(PATH));
      bufWriter.write("输入");
      bufWriter.close();
   }catch(IOException e){
      e.printStackTrace();
   }

读取节点:

try{
     BufferedReader reader = new BufferedReader(new FileReader(PATH));
     String result = reader.readLine();
     if (result != null) {
       //写入判断逻辑
     }
   }catch(IOException e){
      e.printStackTrace();
   }
上一篇下一篇

猜你喜欢

热点阅读