Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File paths manipulation in scala

Tags:

scala

Is there some nice way to safely manipulate file paths in Scala, transcending naive string manipulation?

I mean smart concatenation that adds missing slashes between path parts, Unix v.s. Windows slashes, automatically escaping spaces in paths, etc?

What would be a nice Java fallback for that?

like image 786
matanster Avatar asked Oct 24 '25 14:10

matanster


1 Answers

You can do it this way:

import java.io.File

val a = "abc/def"
val b = "ghi/jk"
new File(a,b).getPath
// res0: String = abc/def/ghi/jk
like image 126
dhg Avatar answered Oct 26 '25 11:10

dhg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!