Making a folder/files and writing to them in scala? -
this question has answer here:
- how write file in scala? 13 answers
how can make files , folders in scala , write them? understand how works in other languages, scala bit trickier :/
this different other question because asks how make directories , files in scala.
paul phillips mentioned parenthetically on ml, "i wrote library bunch of wrapping of java.nio.file.path", should wait see came with.
in meantime, previous work on java.io has wandered restless spirit haunts:
scala> import reflect.io._ import reflect.io._ scala> val f = file("my-test.txt") f: scala.reflect.io.file = my-test.txt scala> f writeall ("hello", ",", " ", "world", "\n") scala> :q apm@mara:~/tmp$ cat my-test.txt hello, world
there abstractions path
, directory
.
scala> val d = directory(".") d: scala.reflect.io.directory = . scala> d.list res0: iterator[scala.reflect.io.path] = non-empty iterator scala> d.deeplist() res2: iterator[scala.reflect.io.path] = non-empty iterator scala> d.deepfiles.tolist res4: list[scala.reflect.io.file] = list(./mkarray.scala, ./for29.scala, ./nofunc-wrapped.scala, ./inlined.scala, ./xmlex.scala, ./pet.scala, ./lookup.scala, ./compilertool.scala, ./badvargs.scala, ./tz0.scala, ./discontinuations.jar, ./serious.scala, ./badjunk.scala, ./version.scala, ./shapeless_2.11.jar, ./callbacks.scala, ./delayed.scala, ./privctor0.scala, ./nestedtags.scala, ./hw-repl.scala, ./schema-one.txt, ./tstest.scala, ./badimp.scala, ./matchprim.scala, ./sxemata-all.txt, ./arrow.scala, ./continuations2.jar, ./inliner.scala, ./oneq.scala, ./impmag.scala, ./enumuser.scala, ./auto.save, ./xmlregex.scala, ./strtyp.scala, ./orelse.scala, ./scalac-plugin.xml, ./futuremap.scala, ./applied.save, ./looker.scala, ./pat1, ./sounds.scala, ./shapeless_2.10.jar, ./funkstr.scala, ./stupid.... scala> val p = path(".") p: scala.reflect.io.path = . scala> val f = p / "mkarray.scala" f: scala.reflect.io.path = ./mkarray.scala
Comments
Post a Comment