java - Java中文件操作的事务模式

标签 java transactions

也许我在这里试图解释的内容没有任何意义,所以我想提前道歉。不管怎样,我会努力的。

我正在尝试从文件中读取,执行一些数据库操作并将内容移动到另一个文件。我想知道是否可以在 Java 中以原子方式执行所有这些操作,因此如果操作列表中出现任何问题,请回滚完整序列并返回起点。

提前感谢您的帮助。

最佳答案

看看Apache Commons Transaction .它具有以事务方式管理文件的能力。

archived article详细说明了它在文件系统中的使用。

更新

请注意首页上的状态显示:

We have decided to move the project to dormant as we are convinced that the main advertised feature transactional file access can not be implemented reliably. We are convinced that no such implementation can be possible on top of an ordinary file system. Although there are other useful parts (as multi level locking including deadlock detection) the transactional file system is the main reason people use this library for. As it simply can not be made fully transactional, it does not work as advertised.

关于java - Java中文件操作的事务模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1311050/

相关文章:

java - Java 中的 Breakout Game 在调用 remove() 方法后不传递 boolean 值

java - 排除 Jersey2 响应中的字段

unit-testing - 使用 Spring 3 @Transactional 注解时事务不会回滚

mysql - 在同一事务中插入和更新同一行? (MySQL)

transactions - 领域驱动设计 : Handling atomic operations and transactions

java - Java中int类型的ArrayList的ArrayList?

java - 在 Java 中迭代集合(对于 C++ 程序员)

sql-server-2005 - 我应该如何在 SQL Server 2005 中实现 "autonumber"字段?

java - 如何使用 JPA 和 Hibernate 避免产品销售的竞争条件

java - 在 Apache POI 4.0 中为 XSSFWorkbook 创建自定义颜色样式