mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
java/io bugfixes and coverage; jni bugfixes; minor refactoring
This commit is contained in:
61
classpath/java/io/File.java
Normal file
61
classpath/java/io/File.java
Normal file
@ -0,0 +1,61 @@
|
||||
package java.io;
|
||||
|
||||
public class File {
|
||||
private final String path;
|
||||
|
||||
public File(String path) {
|
||||
if (path == null) throw new NullPointerException();
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public File(String parent, String child) {
|
||||
this(parent + "/" + child);
|
||||
}
|
||||
|
||||
public File(File parent, String child) {
|
||||
this(parent.getPath() + "/" + child);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
int index = path.lastIndexOf("/");
|
||||
if (index >= 0) {
|
||||
return path.substring(index + 1);
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
private static native String toAbsolutePath(String path);
|
||||
|
||||
public String getAbsolutePath() {
|
||||
return toAbsolutePath(path);
|
||||
}
|
||||
|
||||
private static native long length(String path);
|
||||
|
||||
public long length() {
|
||||
return length(path);
|
||||
}
|
||||
|
||||
private static native boolean exists(String path);
|
||||
|
||||
public boolean exists() {
|
||||
return exists(path);
|
||||
}
|
||||
|
||||
private static native void mkdir(String path);
|
||||
|
||||
public void mkdir() {
|
||||
mkdir(path);
|
||||
}
|
||||
|
||||
private static native void createNewFile(String path);
|
||||
|
||||
public void createNewFile() {
|
||||
createNewFile(path);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user