@Test public void testContentCompare() throws Exception { assertEquals( true, fileManipulator.contentEquals( "http: "http: }
public boolean contentEquals( String src, String dest ) throws FileManipulatorException { FileObject srcFile = null; FileObject destFile = null; try { LOGGER.debug( "Comparing the content of {} and {}", src, dest ); srcFile = this.resolveFile( src ); destFile = this.resolveFile( dest ); if ( !srcFile.exists() || !destFile.exists() ) { LOGGER.debug( "{} or {} don't exist", src, dest ); return false; } if ( !srcFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The source {} is not a file", src ); throw new IllegalArgumentException( "The source URI " + src + " is not a file" ); } if ( !destFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The destination {} is not a file", dest ); throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" ); } return IOUtils.contentEquals( srcFile.getContent().getInputStream(), destFile.getContent().getInputStream() ); } catch ( Exception e ) { LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e ); throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e ); } finally { if ( srcFile != null ) { try { srcFile.close(); } catch ( Exception e ) { } } if ( destFile != null ) { try { destFile.close(); } catch ( Exception e ) { } } } }
FileManipulator { public boolean contentEquals( String src, String dest ) throws FileManipulatorException { FileObject srcFile = null; FileObject destFile = null; try { LOGGER.debug( "Comparing the content of {} and {}", src, dest ); srcFile = this.resolveFile( src ); destFile = this.resolveFile( dest ); if ( !srcFile.exists() || !destFile.exists() ) { LOGGER.debug( "{} or {} don't exist", src, dest ); return false; } if ( !srcFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The source {} is not a file", src ); throw new IllegalArgumentException( "The source URI " + src + " is not a file" ); } if ( !destFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The destination {} is not a file", dest ); throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" ); } return IOUtils.contentEquals( srcFile.getContent().getInputStream(), destFile.getContent().getInputStream() ); } catch ( Exception e ) { LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e ); throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e ); } finally { if ( srcFile != null ) { try { srcFile.close(); } catch ( Exception e ) { } } if ( destFile != null ) { try { destFile.close(); } catch ( Exception e ) { } } } } }
FileManipulator { public boolean contentEquals( String src, String dest ) throws FileManipulatorException { FileObject srcFile = null; FileObject destFile = null; try { LOGGER.debug( "Comparing the content of {} and {}", src, dest ); srcFile = this.resolveFile( src ); destFile = this.resolveFile( dest ); if ( !srcFile.exists() || !destFile.exists() ) { LOGGER.debug( "{} or {} don't exist", src, dest ); return false; } if ( !srcFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The source {} is not a file", src ); throw new IllegalArgumentException( "The source URI " + src + " is not a file" ); } if ( !destFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The destination {} is not a file", dest ); throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" ); } return IOUtils.contentEquals( srcFile.getContent().getInputStream(), destFile.getContent().getInputStream() ); } catch ( Exception e ) { LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e ); throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e ); } finally { if ( srcFile != null ) { try { srcFile.close(); } catch ( Exception e ) { } } if ( destFile != null ) { try { destFile.close(); } catch ( Exception e ) { } } } } FileManipulator(); }
FileManipulator { public boolean contentEquals( String src, String dest ) throws FileManipulatorException { FileObject srcFile = null; FileObject destFile = null; try { LOGGER.debug( "Comparing the content of {} and {}", src, dest ); srcFile = this.resolveFile( src ); destFile = this.resolveFile( dest ); if ( !srcFile.exists() || !destFile.exists() ) { LOGGER.debug( "{} or {} don't exist", src, dest ); return false; } if ( !srcFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The source {} is not a file", src ); throw new IllegalArgumentException( "The source URI " + src + " is not a file" ); } if ( !destFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The destination {} is not a file", dest ); throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" ); } return IOUtils.contentEquals( srcFile.getContent().getInputStream(), destFile.getContent().getInputStream() ); } catch ( Exception e ) { LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e ); throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e ); } finally { if ( srcFile != null ) { try { srcFile.close(); } catch ( Exception e ) { } } if ( destFile != null ) { try { destFile.close(); } catch ( Exception e ) { } } } } FileManipulator(); void close(); static String getBaseDir(); FileObject resolveFile( String vfsPath ); boolean exists( String vfsPath ); boolean contentEquals( String src, String dest ); boolean checksumEquals( String src, String dest ); void copy( String src, String dest ); boolean isFolder( String vfsPath ); FileObject[] browse( String vfsPath ); InputStream read( String vfsPath ); OutputStream write( String vfsPath ); static String createEnvironmentCacheDir( Environment environment ); static String createJEEApplicationCacheDir( Environment environment, JEEApplication jeeApplication ); static String createSoftwareCacheDir( Environment environment, Software software ); void createDirectory( String path ); static boolean protocolExists( String path ); static String format( String url ); void delete( String path ); static void searchAndReplace( String path, String regex, String substitute ); }
FileManipulator { public boolean contentEquals( String src, String dest ) throws FileManipulatorException { FileObject srcFile = null; FileObject destFile = null; try { LOGGER.debug( "Comparing the content of {} and {}", src, dest ); srcFile = this.resolveFile( src ); destFile = this.resolveFile( dest ); if ( !srcFile.exists() || !destFile.exists() ) { LOGGER.debug( "{} or {} don't exist", src, dest ); return false; } if ( !srcFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The source {} is not a file", src ); throw new IllegalArgumentException( "The source URI " + src + " is not a file" ); } if ( !destFile.getType().equals( FileType.FILE ) ) { LOGGER.error( "The destination {} is not a file", dest ); throw new IllegalArgumentException( "The destination URI " + dest + " is not a file" ); } return IOUtils.contentEquals( srcFile.getContent().getInputStream(), destFile.getContent().getInputStream() ); } catch ( Exception e ) { LOGGER.error( "Can't compare content of {} and {}", new Object[]{ src, dest }, e ); throw new FileManipulatorException( "Can't compare content of " + src + " and " + dest, e ); } finally { if ( srcFile != null ) { try { srcFile.close(); } catch ( Exception e ) { } } if ( destFile != null ) { try { destFile.close(); } catch ( Exception e ) { } } } } FileManipulator(); void close(); static String getBaseDir(); FileObject resolveFile( String vfsPath ); boolean exists( String vfsPath ); boolean contentEquals( String src, String dest ); boolean checksumEquals( String src, String dest ); void copy( String src, String dest ); boolean isFolder( String vfsPath ); FileObject[] browse( String vfsPath ); InputStream read( String vfsPath ); OutputStream write( String vfsPath ); static String createEnvironmentCacheDir( Environment environment ); static String createJEEApplicationCacheDir( Environment environment, JEEApplication jeeApplication ); static String createSoftwareCacheDir( Environment environment, Software software ); void createDirectory( String path ); static boolean protocolExists( String path ); static String format( String url ); void delete( String path ); static void searchAndReplace( String path, String regex, String substitute );  }