]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.project/src/org/simantics/project/management/WorkspaceUtil.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / WorkspaceUtil.java
diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/WorkspaceUtil.java b/bundles/org.simantics.project/src/org/simantics/project/management/WorkspaceUtil.java
new file mode 100644 (file)
index 0000000..959d8e9
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.project.management;\r
+\r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.util.Properties;\r
+\r
+/**\r
+ * Workspace management utils\r
+ *\r
+ * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
+ */\r
+public class WorkspaceUtil {\r
+\r
+       /**\r
+        * Write project properties \r
+        * \r
+        * Project URI is in a text file simantics.cfg \r
+        * \r
+        * @param propertyFile\r
+        * @param props\r
+        * @throws IOException \r
+        */\r
+       public static void writeProperties(File propertyFile, Properties props) throws IOException {\r
+           FileWriter fw = null;\r
+           try {\r
+               fw = new FileWriter( propertyFile );\r
+               props.store(fw, "Project configuration");\r
+           } finally {\r
+               if (fw!=null) fw.close();\r
+           }                           \r
+       }\r
+       \r
+       /**\r
+        * Read project properties in a workspace\r
+        * \r
+        * @param workspace\r
+        * @return\r
+        * @throws IOException\r
+        */\r
+       public static Properties readProperties(File propertyFile) throws IOException {\r
+           FileReader fr = null;\r
+           try {\r
+               fr = new FileReader(propertyFile);              \r
+                       Properties props = new Properties();\r
+                   props.load(fr);\r
+                       return props;\r
+           } finally {\r
+               if (fr!=null) fr.close();\r
+           }\r
+               \r
+       }\r
+\r
+       \r
+}\r
+\r