tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject incubator-tamaya git commit: [TAMAYA-164] Simplified the way how the banner is read from its text file.
Date Sat, 19 Nov 2016 08:57:34 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 5fd0ec9bd -> ad1562867


[TAMAYA-164] Simplified the way how the banner is read from its text file.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/ad156286
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/ad156286
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/ad156286

Branch: refs/heads/master
Commit: ad15628674ce029ef99bee52d7ef1b2dea449c6b
Parents: 5fd0ec9
Author: Oliver B. Fischer <plexus@apache.org>
Authored: Sat Nov 19 09:52:20 2016 +0100
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Sat Nov 19 09:57:23 2016 +0100

----------------------------------------------------------------------
 .../apache/tamaya/ConfigurationProvider.java    | 35 ++++++++------------
 1 file changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ad156286/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
index 9f4baa0..9aa54b7 100644
--- a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
+++ b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
@@ -23,10 +23,12 @@ import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.ConfigurationProviderSpi;
 import org.apache.tamaya.spi.ServiceContextManager;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
 
 /**
  * Static access to the {@link Configuration} for the very application.
@@ -46,32 +48,21 @@ public final class ConfigurationProvider {
     }
 
     private static void showBanner() {
-        BufferedReader reader = null;
         try{
             URL url = ConfigurationProvider.class.getResource("/tamaya-banner.txt");
-            if(url!=null){
-                reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
-                StringBuilder b = new StringBuilder();
-                String line = reader.readLine();
-                while(line != null){
-                    b.append(line).append('\n');
-                    line = reader.readLine();
+
+            if (url!=null) {
+                Path path = Paths.get(url.toURI());
+                List<String> content = Files.readAllLines(path, StandardCharsets.UTF_8);
+
+                for (String line : content) {
+                    System.out.println(line);
                 }
-                System.out.println(b.toString());
             }
         }
-        catch(Exception e){
+        catch (Exception e){
             System.out.println("************ TAMAYA CONFIG ************");
         }
-        finally{
-            if(reader!=null){
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
     }
 
     private ConfigurationProvider() {


Mime
View raw message