English 中文(简体)
我怎么能够创建并撰写一份档案文件,从另一个过程读到,而不必面对阅读/标准问题(Java/EE)。
原标题:How can I create and write a File one Java Process and read from another process without facing read/write problems(Java/EE)

MY 局势

我有一个程序,即FTP和另一个电子邮件程序。

While I am done with FTP I want to email a success notification. So the email process is watching for a new file pr configuration file to come in to a particular directory

外籍人权利论坛程序创建了一个适合电子邮件程序的文件,在财产档案中,电子邮件越来越多或更少。

我面临的问题是,在我创建档案并撰写文件时。 电子邮件程序对新档案进行检测,并在文件编写之前或提交时予以公布。 因此,它只能使用无效参数。 虽然我可以把睡在电子邮件程序之上,但它不会对所有案件工作,而且会阻碍其他填写档案的人。

What can I use to -create a property file which cannot be read untill it is completely written -or create a property file with a lock which can be unlocked from another process if need be.

我的选择是什么?

As far as now: - I have tried using apache commons configuration to setProperty it created the same old read/write access problem - I created a property =new property and used store method to create the file. Even then the Email process would read before it is completely

FYI:Email Process有“望报”,在创建新档案时写。

问题回答

您需要从事与档案系统有关的“分类”业务。 在另一个档案名称(例如:tmpfoobar)下以及在你重新填写、关闭并填写<代码>File.renameTo(,以便将其付诸实施。 名称为原子。

不清楚为什么你退席,因为这似乎是一个值得的问题。

Martin建议使用改名的档案来完成这项工作:首先用临时名字书写档案,然后改名。 然后,如果另一个过程/现在只能查阅更名的档案,那么你就应当好,因为重新命名确实是原子的。

如果你采用多读应用方法,则采取另一种办法,即使用某种中上下限,以确保读像不会读到,直到档案被书面读写者关闭为止。

该网页和其他位于javamex.com的网页对 Java并行方案规划作了一些很好的解释:

http://www.javamex.com/tutorials/synchronization_concurrency_1.shtml





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签