ืงืืืช ืกืคืจืืืช ืืขืืืื ืื ืืืืืช ื-Java ืคืืจืืฉื ืงืืืช ืื ืชืื ืฉื ืืกืคืจืืื (ืืชืืงืื) ืืื ื ืืืฉืงื ืืชืืื ืืช ืฉืื. ืืืจื ืืื, ืื ืืืืจ ืืงืื ืืช ืื ืชืื ืืชืืงืืืช ืืฉืืจืฉ ืืชืืงืื ืฉืื ืืืฆื ืงืืืฅ ืืชืืื ืืช. ืืืื ืืขืื ื ืคืืฆื ืืืืืืืืช ืืืฉื ื ืืกืคืจ ืืจืืื ืืขืฉืืช ืืืช ื-Java. ืขื ืืืช, ื ืชืืื ืขื ืืืกืืกื ืืืืชืจ ืชืื ืฉืืืืฉ ืืฉืืื ืืืืื ืืช ืฉื ืืืขืจืืช.
ืืืืฆืขืืช System.getProperty(); ืฉืืื
public class DriverClass {
public static void main(String[] args) {
String userDirectoryPath = System.getProperty("user.dir");
System.out.println("Current Directory = \"" + userDirectoryPath + "\"" );
}
}
ืชึฐืคืึผืงึธื
Current Directory = "C:\Users\DELL\eclipse-workspace\JavaProjects"
ืึถืกืึผึตืจ
ืงืืข ืืงืื ืฉืืืขืื ืืฉืชืืฉ ืืฉืืืช " getProperty() " ืืืกืืคืงืช ืขื ืืื " System " ืขื ืืคืจืืืจ ืืกืื ืืจืื " user.dir ". ืืื ืืืื ืืช ืื ืชืื ืฉื ืืกืคืจืืื ืืืืืื ืืช ืคืจืืืงื ื-Java ืฉืื. ืืคืขื ืืืชื ืืขืฆืื ืืชืจืื ืฉืืื ืืืืคืก ืืคืื.ืฉืืืืฉ ื-java.nio.file.FileSystems
import java.nio.file.FileSystems;
import java.nio.file.Path;
public class DriverClass1 {
// Print Current Working Directory using File Systems
static void printCurrentWorkingDirectoryUsingFileSystems() {
Path currentDirectoryPath = FileSystems.getDefault().getPath("");
String currentDirectoryName = currentDirectoryPath.toAbsolutePath().toString();
System.out.println("Current Directory = \"" + currentDirectoryName + "\"");
}
public static void main(String[] args) {
printCurrentWorkingDirectoryUsingFileSystems();
}
}
ืชึฐืคืึผืงึธื
Current Directory = "C:\Users\DELL\eclipse-workspace\JavaProjects"
GO TO FULL VERSION