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

The following examples show how to use java.io.File#getClass() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   File: ProvidedExtensionsTest.java    License: 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 Project: netbeans   File: ProvidedExtensionsTest.java    License: 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 Project: netbeans   File: FileUtil.java    License: 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
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 Project: netbeans   File: ProvidedExtensionsTest.java    License: Apache License 2.0 4 votes vote down vote up
public void beforeMove(FileObject fo, File to) {
    to.getClass();
    assertLock();
    beforeMoveCalls++;
}
 
Example 6
Source Project: netbeans   File: ProvidedExtensionsTest.java    License: Apache License 2.0 4 votes vote down vote up
public void moveSuccess(FileObject fo, File to) {
    to.getClass();
    assertLock();
    moveSuccessCalls++;
}
 
Example 7
Source Project: netbeans   File: ProvidedExtensionsTest.java    License: Apache License 2.0 4 votes vote down vote up
public void moveFailure(FileObject fo, File to) {
    to.getClass();
    assertLock();
    moveFailureCalls++;
}
 
Example 8
Source Project: netbeans   File: ProvidedExtensionsTest.java    License: Apache License 2.0 4 votes vote down vote up
public void beforeCopy(FileObject fo, File to) {
    to.getClass();
    assertLock();
    beforeCopyCalls++;
}
 
Example 9
Source Project: netbeans   File: ProvidedExtensionsTest.java    License: Apache License 2.0 4 votes vote down vote up
public void copySuccess(FileObject fo, File to) {
    to.getClass();
    assertLock();
    copySuccessCalls++;
}
 
Example 10
Source Project: netbeans   File: ProvidedExtensionsTest.java    License: Apache License 2.0 4 votes vote down vote up
public void copyFailure(FileObject fo, File to) {
    to.getClass();
    assertLock();
    copyFailureCalls++;
}