Non-static method wrappers for Files.readAllLines and Files.write
ef69e80510
Bumps [junit-jupiter](https://github.com/junit-team/junit5) from 5.7.2 to 5.9.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.7.2...r5.9.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> |
||
---|---|---|
.github | ||
src | ||
.gitignore | ||
pom.xml | ||
README.md |
File Reader/Writer
Simple wrapper for the static methods Files.readAllLines
and Files.write
,
bringing into simple classes that can be injected into code using Dependency
Injection allowing them to be mocked during testing without touching the real
filesystem.
Assumptions
- All files will be read and written in
ÙTF-8
. - When reading a file lines breaks will be replaced by the newline character.
- When writing a file it will be truncated first.
Usage
Jakarta EE
@Produces
FileReaderWriter fileReaderWriter() {
return new FileReaderWriter();
}
@Produces
FileReader fileReader() {
return new FileReaderWriter();
}
@Produces
FileWriter fileWriter() {
return new FileReaderWriter();
}
Spring
@Bean
FileReaderWriter fileReaderWriter() {
return new FileReaderWriter();
}
@Bean
FileReader fileReader() {
return new FileReaderWriter();
}
@Bean
FileWriter fileWriter() {
return new FileReaderWriter();
}