检查文件是否阅读它之前打开? [英] Check if a file is open before reading it?

查看:126
本文介绍了检查文件是否阅读它之前打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使小程序读取本地文件系统上的一个非常频繁的时间间隔(数次第二)的文件(用户计算机),然后使文件提供给经由所述网页的内容JavaScript的。

I'm trying to make an applet that reads a file on the local file system (the users computer) at a very frequent interval (several times a second), then makes the contents of the file available to the web page via javascript.

的文件中的小程序需要读取由用户的计算机上的程序以高频率更新。我很担心的是,当该文件是在被更新的中间,如果小程序从文件中读取数据,可能会发生什么。

The file the applet needs to read is updated at a high frequency by a program on the user's computer. What I'm concerned about is what might happen if the applet reads data from the file when the file is in the middle of being updated.

我不知道该怎么可能这是的,但如果它是一个有效的关注是有办法,以确保该文件没有被阅读之前写?

I don't know how likely this is, but if it is a valid concern is there a way to make sure the file is not currently being written to before reading it?

推荐答案

我不看好这个,但你可以尝试的 java.io.FileInputStream中的 ,或从包中一些其他的选择。

I'm not positive about this, but you could try java.io.FileInputStream, or some other option from that package.

此外,这个问题可能是重复的。这可能会回答你的问题:

Also, this question may be a duplicate. This might answer your question:


  1. How我使用Java从正在被写入一个文件中读取?

  2. 读取一个文件,而它的写入

  3. 阅读文件,而它被写入

  4. Reading从文件数据,同时它被写入

  1. How do I use Java to read from a file that is actively being written?
  2. reading a file while it's being written
  3. Read a file while it's being written
  4. Reading data from a File while it is being written to

这篇关于检查文件是否阅读它之前打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆