Open archive file through a java route

0

I use the following code to call the route:

String url= "\"C:\users\Jose\Documents\video\"";

ProcessBuilder p = ProcessBuilder();
p.command("cmd.exe","\c",url);

NOTE: this code works perfectly for me, the file address is either video or a program, but I want to place a relative path. I mean I want my program to take it to another machine keep opening the files.

How do I open the address when placing my program on another machine?

    
asked by tiugre 22.11.2017 в 00:21
source

1 answer

1

Try this way:

We create an instance File as follows:

File file = new File();

in order to have access to the metadata of the system of files, and with the class

System.getProperty

We recover the property that you  we are indicating, in this case it is the user name of the system  "user.name" this will return the current username

File user = new File(System.getProperty("user.name"));

String url ="C:\Users\" + user + "\Documents\video\";
    
answered by 27.02.2018 в 01:21