@Test public void testReadURL() throws Exception { String urlPom = FileUtils.readFileToString( fileIO.resolveURL( mockServer.getUrl() ), StandardCharsets.UTF_8 ); String filePom = FileUtils.readFileToString( new File ( new File (FileIOTest.class.getResource( "/" ).getPath()) .getParentFile().getParentFile(), "pom.xml"), StandardCharsets.UTF_8 ); assertEquals( urlPom, filePom ); }
public File resolveURL( final String reference ) throws IOException { URL ref; File result; if ( SystemUtils.IS_OS_WINDOWS ) { ref = new URL( reference.replaceFirst( "^file: } else { ref = new URL( reference ); } if ( !"file".equals( ref.getProtocol() ) ) { File cache = infra.getCacheDir(); result = new File( cache, UUID.randomUUID().toString() ); FileUtils.copyURLToFile( ref, result ); } else { result = new File( ref.getPath() ); } return result; }
FileIO { public File resolveURL( final String reference ) throws IOException { URL ref; File result; if ( SystemUtils.IS_OS_WINDOWS ) { ref = new URL( reference.replaceFirst( "^file: } else { ref = new URL( reference ); } if ( !"file".equals( ref.getProtocol() ) ) { File cache = infra.getCacheDir(); result = new File( cache, UUID.randomUUID().toString() ); FileUtils.copyURLToFile( ref, result ); } else { result = new File( ref.getPath() ); } return result; } }
FileIO { public File resolveURL( final String reference ) throws IOException { URL ref; File result; if ( SystemUtils.IS_OS_WINDOWS ) { ref = new URL( reference.replaceFirst( "^file: } else { ref = new URL( reference ); } if ( !"file".equals( ref.getProtocol() ) ) { File cache = infra.getCacheDir(); result = new File( cache, UUID.randomUUID().toString() ); FileUtils.copyURLToFile( ref, result ); } else { result = new File( ref.getPath() ); } return result; } @Inject  FileIO(@Named( "galley" ) GalleyInfrastructure infra ); }
FileIO { public File resolveURL( final String reference ) throws IOException { URL ref; File result; if ( SystemUtils.IS_OS_WINDOWS ) { ref = new URL( reference.replaceFirst( "^file: } else { ref = new URL( reference ); } if ( !"file".equals( ref.getProtocol() ) ) { File cache = infra.getCacheDir(); result = new File( cache, UUID.randomUUID().toString() ); FileUtils.copyURLToFile( ref, result ); } else { result = new File( ref.getPath() ); } return result; } @Inject  FileIO(@Named( "galley" ) GalleyInfrastructure infra ); File resolveURL( final String reference ); }
FileIO { public File resolveURL( final String reference ) throws IOException { URL ref; File result; if ( SystemUtils.IS_OS_WINDOWS ) { ref = new URL( reference.replaceFirst( "^file: } else { ref = new URL( reference ); } if ( !"file".equals( ref.getProtocol() ) ) { File cache = infra.getCacheDir(); result = new File( cache, UUID.randomUUID().toString() ); FileUtils.copyURLToFile( ref, result ); } else { result = new File( ref.getPath() ); } return result; } @Inject  FileIO(@Named( "galley" ) GalleyInfrastructure infra ); File resolveURL( final String reference );  }