下面列出了java.io.File#getClass ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public ProvidedExtensions.IOHandler getMoveHandler(final File from, final File to) {
to.getClass();
implsMoveCalls++;
return (!isImplsMoveRetVal() || to == null) ? null : new ProvidedExtensions.IOHandler(){
public void handle() throws IOException {
moveImplCalls++;
if (to.exists()) {
throw new IOException();
}
assertTrue(from.exists());
assertFalse(to.exists());
assertFalse(from.equals(to));
if (from.isDirectory()) {
from.renameTo(to);
} else {
InputStream inputStream = new FileInputStream(from);
OutputStream outputStream = new FileOutputStream(to);
try {
FileUtil.copy(inputStream, outputStream);
} finally {
if (inputStream != null) inputStream.close();
if (outputStream != null) outputStream.close();
}
to.setLastModified(from.lastModified());
assertTrue(from.delete());
}
assertFalse(from.exists());
assertTrue(to.exists());
}
};
}
@Override
public ProvidedExtensions.IOHandler getCopyHandler(final File from, final File to) {
to.getClass();
if (from.isDirectory()) {
return null;
}
implsCopyCalls++;
return (!isImplsCopyRetVal() || to == null) ? null : new ProvidedExtensions.IOHandler(){
@Override
public void handle() throws IOException {
copyImplCalls++;
if (to.exists()) {
throw new IOException();
}
assertTrue(from.exists());
assertFalse(to.exists());
assertFalse(from.equals(to));
InputStream inputStream = new FileInputStream(from);
OutputStream outputStream = new FileOutputStream(to);
try {
FileUtil.copy(inputStream, outputStream);
} finally {
if (inputStream != null) inputStream.close();
if (outputStream != null) outputStream.close();
}
assertTrue(from.exists());
assertTrue(to.exists());
}
};
}
static String toDebugString(File file) {
if (file == null) {
return "NULL-ref"; // NOI18N
} else {
return file.getPath() + "(" + file.getClass() + ")"; // NOI18N
}
}
public static boolean startsWith(File f,File s){
return f.getClass()==s.getClass()&&(f.getPath().equals(s.getPath())||f.getParentFile().getPath().startsWith(s.getPath()));
}
public void beforeMove(FileObject fo, File to) {
to.getClass();
assertLock();
beforeMoveCalls++;
}
public void moveSuccess(FileObject fo, File to) {
to.getClass();
assertLock();
moveSuccessCalls++;
}
public void moveFailure(FileObject fo, File to) {
to.getClass();
assertLock();
moveFailureCalls++;
}
public void beforeCopy(FileObject fo, File to) {
to.getClass();
assertLock();
beforeCopyCalls++;
}
public void copySuccess(FileObject fo, File to) {
to.getClass();
assertLock();
copySuccessCalls++;
}
public void copyFailure(FileObject fo, File to) {
to.getClass();
assertLock();
copyFailureCalls++;
}