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
))
}
Source: stackoverflow.com
Related Query
- Scala and html: download an image (*.jpg, etc) to Hard drive
- Scala and HTML parsing
- Writing a functional and yet functional image processing library in Scala
- Scala / Lift - Trying to understand Lift's simultaneous claim to use valid html and propensity for lift: tags and tag rewriting in render
- Scala image resize and crop
- Play scala browse the image then crop and submit into form
- How programmatically limit download speed on server with Scala and Play
- image display using play framework and scala
- Image files and relative paths in scala
- Trying to make use of Jcrop and serverside image resizing with scala Scrimage lib
- scala sbt: how to find out and download dependencies automatically just like go get?
- Thymeleaf with springboot and Scala not rendering HTML page
- Using play framework and scala how to display image path from database
- Scala image compression and optimisation
- Get image data from Html5 canvas and upload it to Amazon S3 server, using Scala
- How to use scala and html code inside single block
- Is there a way to convert Scala-Spark DataFrame to HTML table, or converting DataFrame to Scala map then convert to Json and then HTML?
- Scala IDE 3.0.4 editor support for html and sbt
- Dynamic HTML ID with Bootstrap, Play framework and Scala templates
- Play Framework: How to resize and convert to JPG an image after upload
- How might I use HTML 5 for Scala input and output?
- How to manage html inside application which uses spray and scala
- Convert Array[AnyVal] to primitive Array[T], T can be Int, Double and etc in scala
- download gz file on clicking a url and convert to csv using scala
- Format a string and replace %s with html element in scala play framework
- Embed a image to eclipse and display it with scala
- Download Scala and Spark API docs?
- how to convert image (.jpg) to array in scala and how to count the green pixel in the same array using scala
- Fixing my Scala Intellij project when loading it from an existing project in sbt and dependencies download fails
- Scala @ Functions/Language for HTML documentation - for loop, if statement, etc
More Query from same tag
- scalatra 2.2.0 upgrade encountered NoClassDefFoundError:GenTraversableLike
- What does the `effect` mean in `scalaz-effect`
- Tuple parameter declaration and assignment oddity
- Why does this list-of-futures to future-of-list transformation compile and work?
- Spark UDF how to convert Map to column
- Understanding Scala -> syntax
- Chisel: how to avoid errors NO DEFAULT SPECIFIED FOR WIRE
- Representing nested structures in scala
- PartialFunction with recursion
- How to use Future in database access
- Syntax for writing a method that accepts an object that has a specific method
- How establish Scalatest in a Play project with intelliJ
- Single quotes cause trouble while filtering in Slick
- How to nicely transform a Try[Unit] to a Unit while handling certain exceptions?
- Regex / subString to extract all matching patterns / groups
- Cloning an instance of a class, but not exactly
- Fill empty cells with duplicates in a DataFrame
- combination of array elements in scala
- Serializing Generic Scala Types with Gson
- BSONDocument.getAs issue
- Spray route testing with Akka TestProbe
- underscore for generic type argument produces compile error in Scala?
- How to debug Scala Macros using Eclipse
- Custom datasource plugin on EMR throwing java.lang.NoClassDefFoundError: scalaj/http/Http
- Strange Behaviour Using Scala Parallel Collections and setParallelism
- Clarification needed about Scala variance and type bounds
- How do I create objects based on user input in Scala?
- Play! framework 2.0 scala - ClassCastException: models.MyModel cannot be cast to models.MyModel
- Why does "+" operator work even without space between the operands in Scala
- Overcoming erasure case study; currying Maps