Apache HttpClient를 사용하여 스칼라 REST 클라이언트를 만들고 있습니다. 내 코드는 다음과 같습니다.Scala에서 REST 클라이언트와 관련된 문제
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
}
문제는 Source
가 io.Source
에 빨간색으로 표시되어 있다는 점이다. 그것은 Cannot resolve symbol source
라고합니다. 또한 import java.io._
은 사용하지 않는 것으로 표시됩니다. 이 문제를 해결하는 방법?