score:3

Accepted answer

Then you may want to take a look at java2s. Although the solution is in plain Java but you can still modify to Scala syntax to "just use it"

score:0

One way to achieve that is: collect the URLs of the images and ask for them to the server (open a new connection with the image url and store the bytestream in the hard drive)

score:2

An alternative option is to use the system commands which is much cleaner

import sys.process._
import java.net.URL
import java.io.File

object Downloader {
  def start(location: String) : Unit = {
    val url = new URL(location)

    var path = url match {
      case UrlyBurd(protocol, host, port, path) => (if (path == "") "/" else path)
    }

    path = path.substring(path.lastIndexOf("/") + 1)

    url #> new File(path) !!
  }
}

object UrlyBurd {
  def unapply(in: java.net.URL) = Some((
    in.getProtocol, 
    in.getHost, 
    in.getPort,
    in.getPath
  ))
}

Related Query

More Query from same tag