Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java Example – Viewing the Current Working Directory

Java Example – Viewing the Current Working Directory

Java Examples Java Examples

The following example demonstrates using the System.getProperty() method to get the current working directory:

Main.java File

class

Main

{

public

static

void

main

(

String

[

]

args

)

{

String

curDir

=

System

.

getProperty

(

"

user.dir

"

)

;

System

.

out

.

println

(

"

Your current working directory is:

"

curDir

)

;

}

}

The output of the above code is:


你当前的工作目录为 :/www/java

Java Examples Java Examples