]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/management/WorkspaceUtil.java
Merge commit '728147df5d63a3333daff3d8c0e9bfd4f5597e3a'
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / WorkspaceUtil.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.project.management;\r
13 \r
14 import java.io.File;\r
15 import java.io.FileReader;\r
16 import java.io.FileWriter;\r
17 import java.io.IOException;\r
18 import java.util.Properties;\r
19 \r
20 /**\r
21  * Workspace management utils\r
22  *\r
23  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
24  */\r
25 public class WorkspaceUtil {\r
26 \r
27         /**\r
28          * Write project properties \r
29          * \r
30          * Project URI is in a text file simantics.cfg \r
31          * \r
32          * @param propertyFile\r
33          * @param props\r
34          * @throws IOException \r
35          */\r
36         public static void writeProperties(File propertyFile, Properties props) throws IOException {\r
37             FileWriter fw = null;\r
38             try {\r
39                 fw = new FileWriter( propertyFile );\r
40                 props.store(fw, "Project configuration");\r
41             } finally {\r
42                 if (fw!=null) fw.close();\r
43             }                           \r
44         }\r
45         \r
46         /**\r
47          * Read project properties in a workspace\r
48          * \r
49          * @param workspace\r
50          * @return\r
51          * @throws IOException\r
52          */\r
53         public static Properties readProperties(File propertyFile) throws IOException {\r
54             FileReader fr = null;\r
55             try {\r
56                 fr = new FileReader(propertyFile);              \r
57                         Properties props = new Properties();\r
58                     props.load(fr);\r
59                         return props;\r
60             } finally {\r
61                 if (fr!=null) fr.close();\r
62             }\r
63                 \r
64         }\r
65 \r
66         \r
67 }\r
68 \r