Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i convert a FilePath to a File?

I'm writing a Jenkins plugin and i'm using build.getWorkspace() to get the path to the current workspace. The issue is that this returns a FilePath object.

How can i convert this to a File object?

like image 312
daniels Avatar asked Nov 04 '13 23:11

daniels


People also ask

Can a URI be a file path?

A valid file URI must therefore begin with either file:/path (no hostname), file:///path (empty hostname), or file://hostname/path . file://path (i.e. two slashes, without a hostname) is never correct, but is often used.


1 Answers

Although I haven't tried this, according to the javadoc you can obtain the URI from which you can then create a file: File myFile = new File(build.getWorkspace().toURI())

like image 136
Morfic Avatar answered Sep 20 '22 06:09

Morfic