Read & write delimited text files like EasyExcel. Annotation-based Bean mapping, 2G+ large file support, batch processing.
// Read: 3 lines
EasyTxt.read(file, UserBean.class, ",", new BeanReadListener()).doRead();
// Write: 3 lines
EasyTxt.write(file, UserBean.class, ",", pageNo, pageSize, this::queryPage).doWrite();- Annotation-based Bean mapping —
@TxtFiled,@DateFormatFiled,@NumberFormatFiled - Two index modes — Fixed-index & auto-ascending index
- Batch read/write — Paginated callbacks for large datasets
- 2G+ large file support — 111s write / 105s read for 2.52GB (see benchmark below)
- Rich type conversion — String, int, long, BigDecimal, Date, LocalDate, LocalDateTime, and more
- Custom separator — CSV, pipe (
|), tab, or any delimiter - Zero heavy framework — No Spring, pure Java + Hutool + Commons IO
| Feature | easy-txt | OpenCSV | Apache Commons CSV |
|---|---|---|---|
| Annotation Bean mapping | ✅ | ❌ (via MappingStrategy) | ❌ |
| Batch page callback | ✅ | ❌ | ❌ |
| 2G+ large file | ✅ | ✅ | ✅ |
| Custom separator | ✅ | ✅ | ✅ |
| Type converters built-in | ✅ (15+ types) | ❌ | |
| Date/Number format annotations | ✅ | ❌ | ❌ |
<dependency>
<groupId>com.small</groupId>
<artifactId>easy-txt-core</artifactId>
<version>1.1.0</version>
</dependency>implementation 'com.small:easy-txt-core:1.1.0'git clone https://github.com/sm-rose/easy-txt.git
cd easy-txt
mvn clean packageThe JAR will be generated at easy-txt-core/target/easy-txt-core-1.1.0.jar.
@Data
public class UserBean {
@TxtFiled(index = 0)
private String name;
@TxtFiled(index = 1)
private int age;
@TxtFiled(index = 2)
private BigDecimal salary;
@TxtFiled(index = 3)
@DateFormatFiled("yyyy-MM-dd")
private Date birth;
}// Line-by-line via listener
EasyTxt.read(file, UserBean.class, ",", new BeanReadListener()).doRead();
// Batch via consumer
EasyTxt.read(file, BeanTestVO.class, "\\|", pageSize, pageList -> {
pageList.forEach(System.out::println);
}).doRead();EasyTxt.write(file, BeanTest.class, ",", pageNo, pageSize, (pNum, pSize) -> {
return queryPageData(pNum, pSize);
}).doWrite();Full examples in the
easy-txt-testmodule.
Environment: Windows 10, 16GB RAM, mechanical HDD (4 years old).
| Operation | Rows | Size | Time |
|---|---|---|---|
| Write | 2,000,000 | 2.52 GB | 111s |
| Read | 2,000,000 | 2.52 GB | 105s |
| Operation | Rows | Size | Time |
|---|---|---|---|
| Write | 8,000,000 | 2.21 GB | 186s |
| Read | 8,000,000 | 2.52 GB | 223s |
See BigFileDemoTest and BigFileTypeDemoTest.
