/**

     * 等待文件(非目录)读写完毕,费时的操作,不要放在主线程

     *

     * @param file 文件

     */

    private void waitForWirtenCompleted(File file) {

        if (!file.exists())

            return;

        long old_length;

        do {

            old_length = file.length();

            try {

                Thread.sleep(3000);

            } catch (InterruptedException e) {

                e.printStackTrace();

            }

            Log.i("waitForWirtenCompleted: ", old_length + " " + file.length());

 

        } while (old_length != file.length());

    }

  判断文件长度的方法不适用于粘贴复制程度的判断,粘贴复制一般file.length()时固定的不会有写入写出。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
  • 2021-11-01
  • 2021-07-16
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-06-12
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案