Non-static method wrappers for Files.readAllLines and Files.write
7db21d024e
* Bump tiles-maven-plugin from 2.17 to 2.18 Bumps [tiles-maven-plugin](https://github.com/repaint-io/maven-tiles) from 2.17 to 2.18. - [Release notes](https://github.com/repaint-io/maven-tiles/releases) - [Changelog](https://github.com/repaint-io/maven-tiles/blob/master/CHANGELOG.adoc) - [Commits](https://github.com/repaint-io/maven-tiles/compare/tiles-maven-plugin-2.17...tiles-maven-plugin-2.18) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Test build with JDK 15 Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Paul Campbell <pcampbell@kemitix.net> |
||
---|---|---|
.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();
}