How do I rename a file in Scala?

后端 未结 3 1783
一生所求
一生所求 2021-01-12 10:12

I want to rename a file in the system by Scala code. The equivalent of what can be done by bash like,

mv old_file_name new_file_name

I am

3条回答
  •  一生所求
    2021-01-12 10:48

    See renameTo of java.io.File. In your case this would be

    new File("old_file_name").renameTo(new File("new_file_name"))
    

提交回复
热议问题