blob: ee74f35f43613ff2c13176e886c5d522dea55cb1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package forge
import java.nio.{file => jnio}
trait ReadWrite[T] {
def write(t: T, p: jnio.Path): Unit
def read(p: jnio.Path): T
}
object ReadWrite{
implicit object String extends ReadWrite[java.lang.String]{
def write(t: String, p: jnio.Path) = {
jnio.Files.createDirectories(p.getParent)
jnio.Files.deleteIfExists(p)
jnio.Files.write(p, t.getBytes)
}
def read(p: jnio.Path) = {
new String(jnio.Files.readAllBytes(p))
}
}
}
|