From f4bcfe76944585321bd239b48d6df25abe337cbb Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 24 May 2019 08:20:01 +0200 Subject: update IConfiguration interfaces to support SpringBoot resources as configuration source --- .../at/gv/egiz/eaaf/core/impl/utils/FileUtils.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/FileUtils.java') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/FileUtils.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/FileUtils.java index 16b0d321..fff83e53 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/FileUtils.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/FileUtils.java @@ -54,9 +54,9 @@ public class FileUtils { * @throws IOException on any exception thrown */ public static byte[] readURL(String urlString) throws IOException { - URL url = new URL(urlString); - InputStream in = new BufferedInputStream(url.openStream()); - byte[] content = StreamUtils.readStream(in); + final URL url = new URL(urlString); + final InputStream in = new BufferedInputStream(url.openStream()); + final byte[] content = StreamUtils.readStream(in); in.close(); return content; } @@ -68,9 +68,9 @@ public class FileUtils { * @throws IOException on any exception thrown */ public static byte[] readResource(String name) throws IOException { - ClassLoader cl = FileUtils.class.getClassLoader(); - BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name)); - byte[] content = StreamUtils.readStream(in); + final ClassLoader cl = FileUtils.class.getClassLoader(); + final BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name)); + final byte[] content = StreamUtils.readStream(in); in.close(); return content; } @@ -82,7 +82,7 @@ public class FileUtils { * @throws IOException on any exception thrown */ public static String readResource(String name, String encoding) throws IOException { - byte[] content = readResource(name); + final byte[] content = readResource(name); return new String(content, encoding); } @@ -121,7 +121,7 @@ public class FileUtils { if(null == url) return null; - if (url.startsWith("http:/") || url.startsWith("https:/") || url.startsWith("file:/") || url.startsWith("ftp:/")) { + if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:") || url.startsWith("ftp:")) { return url; } else { @@ -146,18 +146,18 @@ public class FileUtils { { try { - byte[] buffer = new byte[ 0xFFFF ]; + final byte[] buffer = new byte[ 0xFFFF ]; for ( int len; (len = fis.read(buffer)) != -1; ) fos.write( buffer, 0, len ); } - catch( IOException e ) { + catch( final IOException e ) { System.err.println( e ); } finally { if ( fis != null ) - try { fis.close(); } catch ( IOException e ) { e.printStackTrace(); } + try { fis.close(); } catch ( final IOException e ) { e.printStackTrace(); } if ( fos != null ) - try { fos.close(); } catch ( IOException e ) { e.printStackTrace(); } + try { fos.close(); } catch ( final IOException e ) { e.printStackTrace(); } } } @@ -167,7 +167,7 @@ public class FileUtils { { copy( new FileInputStream( src ), new FileOutputStream( dest ) ); } - catch( IOException e ) { + catch( final IOException e ) { e.printStackTrace(); } } -- cgit v1.2.3