diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-18 21:16:19 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-18 21:16:19 -0700 |
commit | 538b5ac28b80285953dbea08651cf5c5afa7c0f9 (patch) | |
tree | 22cd2d1dfe2d172124a466b8a0ecf6fff35c9634 /src/main/scala/hbt/ReadWrite.scala | |
parent | 2eab2548bdfe49f246cecfb8718632a84df68342 (diff) | |
download | mill-538b5ac28b80285953dbea08651cf5c5afa7c0f9.tar.gz mill-538b5ac28b80285953dbea08651cf5c5afa7c0f9.tar.bz2 mill-538b5ac28b80285953dbea08651cf5c5afa7c0f9.zip |
Basic evaluator that creates classfiles and a jar now works
Diffstat (limited to 'src/main/scala/hbt/ReadWrite.scala')
-rw-r--r-- | src/main/scala/hbt/ReadWrite.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/scala/hbt/ReadWrite.scala b/src/main/scala/hbt/ReadWrite.scala new file mode 100644 index 00000000..962c0ea4 --- /dev/null +++ b/src/main/scala/hbt/ReadWrite.scala @@ -0,0 +1,20 @@ +package hbt +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)) + } + } +} |