Java Code Examples for java.io.File#getClass()

The following examples show how to use java.io.File#getClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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());
        }
    };
}
 
Example 2
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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());
        }
    };
}
 
Example 3
Source File: FileUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static String toDebugString(File file) {
    if (file == null) {
        return "NULL-ref"; // NOI18N
    } else {
        return file.getPath() + "(" + file.getClass() + ")"; // NOI18N
    }
}
 
Example 4
Source File: FileUtils.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static boolean startsWith(File f,File s){
    return f.getClass()==s.getClass()&&(f.getPath().equals(s.getPath())||f.getParentFile().getPath().startsWith(s.getPath()));
}
 
Example 5
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void beforeMove(FileObject fo, File to) {
    to.getClass();
    assertLock();
    beforeMoveCalls++;
}
 
Example 6
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void moveSuccess(FileObject fo, File to) {
    to.getClass();
    assertLock();
    moveSuccessCalls++;
}
 
Example 7
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void moveFailure(FileObject fo, File to) {
    to.getClass();
    assertLock();
    moveFailureCalls++;
}
 
Example 8
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void beforeCopy(FileObject fo, File to) {
    to.getClass();
    assertLock();
    beforeCopyCalls++;
}
 
Example 9
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void copySuccess(FileObject fo, File to) {
    to.getClass();
    assertLock();
    copySuccessCalls++;
}
 
Example 10
Source File: ProvidedExtensionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void copyFailure(FileObject fo, File to) {
    to.getClass();
    assertLock();
    copyFailureCalls++;
}