From e35dfe2b7bf440d7bb4614439512a9eb333969aa Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Tue, 16 Aug 2016 15:19:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20Sin?= =?UTF-8?q?gleServer:=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=BE=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SingleServer/pom.xml | 4 ++-- .../java/asys/singleserver/Activator.java | 19 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/SingleServer/pom.xml b/SingleServer/pom.xml index 2efa5e4..2442b81 100644 --- a/SingleServer/pom.xml +++ b/SingleServer/pom.xml @@ -20,14 +20,14 @@ asys singleserver - 0.3 + 0.4 bundle asys api - 0.6 + 0.8 org.osgi diff --git a/SingleServer/src/main/java/asys/singleserver/Activator.java b/SingleServer/src/main/java/asys/singleserver/Activator.java index e267af9..7cd1b9c 100644 --- a/SingleServer/src/main/java/asys/singleserver/Activator.java +++ b/SingleServer/src/main/java/asys/singleserver/Activator.java @@ -13,7 +13,8 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import org.osgi.util.tracker.ServiceTracker; -import java.io.*; +import java.io.FileReader; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -60,20 +61,8 @@ public class Activator implements BundleActivator { final String propsFileName = "asys-singleserver.properties"; Path propsPath = Paths.get(confDir).resolve(propsFileName); if (Files.notExists(propsPath)) { - propsPath.toFile().getParentFile().mkdirs(); - - InputStream resourceAsStream = getClass().getResourceAsStream("/"+propsFileName); try { - BufferedWriter bw = new BufferedWriter(new FileWriter(propsPath.toFile())); - BufferedReader br = new BufferedReader(new InputStreamReader(resourceAsStream)); - String line; - while ((line = br.readLine()) != null) { - bw.write(line); - bw.write("\n"); - } - bw.flush(); - bw.close(); - br.close(); + ASysUtils.SaveResource("/"+propsFileName, propsPath.toFile()); } catch (IOException e) { e.printStackTrace(); return null; @@ -82,7 +71,7 @@ public class Activator implements BundleActivator { Properties properties = new Properties(); try { - properties.load(new java.io.FileReader(propsPath.toFile())); + properties.load(new FileReader(propsPath.toFile())); return properties; } catch (IOException e) { e.printStackTrace(); }