0

I am working with Scala in Eclipse IDE on a Windows machine.

I am trying to get a list of files from a specific directory:

    val filesHere = (new java.io.File(".")).listFiles

This provides the file names of all the files in the default directory which is D:\Scala\eclipse. This is confirmed by the following command:

    System.getProperty("user.dir")                  
    > res23: String = D:\Scala\eclipse

I tried changing the directory to a different location with the following command (Based on suggestions from here)

    System.setProperty("user.dir","D:/Scala/")      

Looks like the user directory is changed as confirmed by the following command:

    System.getProperty("user.dir")                  
    > res25: String = D:/Scala/

However, the following command list the files from the default directory and not the new directory:

    val filesHere = (new java.io.File(".")).listFiles

Could someone explain how to make it point to the new directory?

Ravi
  • 3,223
  • 7
  • 37
  • 49

0 Answers0