简体   繁体   中英

Java IO in Scala

I am using Scala and am trying to use Java's IO, but I cannot seem to get it to work. Here is the basis of what I have:

import java.io._
object test{
  def main(args: Array[String]){
   val writer = new PrintWriter(new File("test.txt"))
  }
}

When I try to compile this, I get the following:

Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default-sbt-compile) on project SingleTableSparkScan: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

When I remove the line that uses Java's IO, everything runs fine. Any ideas? Thanks!

I just tried this on http://www.tutorialspoint.com/compile_scala_online.php and the code to compiles and runs.

There must be some kind of other problem with your set up

请试试:

val writer = new PrintWriter(new File("test.txt"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM