Lemon in rain

Lemon under rain:

Posted in Photography, Photos | Tagged , , | Leave a comment

Small bird lake

Bird lake:

Posted in nature, Photography, Photos | Tagged , , , , | Leave a comment

Israeli forest

Ben Shemen forest:

Israeli forest
Posted in Photography, Photos | Tagged , , , | Leave a comment

Israeli forest

Ben Shemen forest:

Israeli forest
Posted in Photography, Photos | Tagged , , , | Leave a comment

Forest windbreak II

Forest windbreak II
Image | Posted on by | Tagged , , , , | Leave a comment

Competition

Competition
Image | Posted on by | Tagged , , , , , | Leave a comment

Forest windbreak

Forest windbreak
Image | Posted on by | Tagged , , , , , , | Leave a comment

Forest still life II

Forest still life II
Image | Posted on by | Tagged , , , , | Leave a comment

Forest still life

Natural forest still lifes:

Forest still life
Forest still life
Posted in Photography, Photos | Tagged , , , | Leave a comment

Scala: How to get file list inside resources?

Sometimes it is necessary to list all files, or files with specific suffix, inside resources.

It should work for file system in the develop stage as well for JAR in production.

A solution is fileNames method:

/**
  * Searches in the resources a list of file names matching a file name suffix
  *
  * @param fileNameSuffix the file name suffix; empty - all files
  * @param folder         specifies a folder; default value is "."
  * @return the list of file names matching a file name suffix
  */
def fileNames(fileNameSuffix: String, folder: String = "."): Seq[String] = {
  new File(Thread
    .currentThread()
    .getContextClassLoader
    .getResource(folder)
    .getPath)
    .listFiles(new FileFilter {
      override def accept(pathname: File): Boolean = {
        pathname.isFile && pathname.getName.endsWith(fileNameSuffix)
      }
    })
    .map(file => file.getName)
}

Code source is here: https://github.com/ysden123/ys-scala-tools/blob/master/src/main/scala/com/stulsoft/scala/tools/resources/ResourceUtils.scala

Posted in Programming, Scala | Tagged , , , | Leave a comment