Ich erstelle einen Scala-REST-Client mit Apache HttpClient. Hier ist mein Code.Probleme mit dem REST-Client in Scala
import java.io._
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.DefaultHttpClient
val output = getRestContent(myURL)
/**
* Returns the text content from a REST URL. Returns a blank String if there
* is a problem.
*/
def getRestContent(url:String): String = {
val httpClient = new DefaultHttpClient()
val httpResponse = httpClient.execute(new HttpGet(url))
val entity = httpResponse.getEntity()
var content = ""
if (entity != null) {
val inputStream = entity.getContent()
content = io.Source.fromInputStream(inputStream).getLines.mkString
inputStream.close
}
httpClient.getConnectionManager().shutdown()
return content
}
Das Problem ist, dass Source
in io.Source
in rot markiert ist. Es sagt Cannot resolve symbol source
. Außerdem ist import java.io._
als unbenutzt markiert. Wie kann ich dieses Problem lösen?