mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
File.length should return 0 for non-existent files
This commit is contained in:
parent
c855224d14
commit
4a9ff55060
@ -331,7 +331,7 @@ Java_java_io_File_length(JNIEnv* e, jclass, jstring path)
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
@ -4,6 +4,10 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileOutput {
|
||||
private static void expect(boolean v) {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
|
||||
private static void test(boolean appendFirst) throws IOException {
|
||||
try {
|
||||
FileOutputStream f = new FileOutputStream("test.txt", appendFirst);
|
||||
@ -33,6 +37,8 @@ public class FileOutput {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
expect(new File("nonexistent-file").length() == 0);
|
||||
|
||||
test(false);
|
||||
test(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user