[ACCEPTED]-Convert java.lang.String to Scala string-scala-java-interop
Accepted answer
It's not a wrapper, but actually java.lang.String. No 1 need in additional hassle:
» touch 123
» scala
...
val foo = new java.io.File("123")
// java.io.File = 123
// Get name is a java api, which returns Java string
foo.getName.toInt
// res2: Int = 123
java.lang.String
is implicitly amended with Scala specific 2 string methods so no manual conversion should 1 be necessary.
Use asInstanceOf[String] to syntactically 1 convert Java string to Scala string.
val str: String = "java_string".asInstanceOf[String]
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.