geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r545196 - /geronimo/sandbox/j2g/configurator/src/org/apache/geronimo/j2g/Configurator.java
Date Thu, 07 Jun 2007 14:37:47 GMT
Author: dwoods
Date: Thu Jun  7 07:37:47 2007
New Revision: 545196

URL: http://svn.apache.org/viewvc?view=rev&rev=545196
Log:
GERONIMO-3224 J2G configurator breaks Eclipse SDK IDE

Modified:
    geronimo/sandbox/j2g/configurator/src/org/apache/geronimo/j2g/Configurator.java

Modified: geronimo/sandbox/j2g/configurator/src/org/apache/geronimo/j2g/Configurator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/configurator/src/org/apache/geronimo/j2g/Configurator.java?view=diff&rev=545196&r1=545195&r2=545196
==============================================================================
--- geronimo/sandbox/j2g/configurator/src/org/apache/geronimo/j2g/Configurator.java (original)
+++ geronimo/sandbox/j2g/configurator/src/org/apache/geronimo/j2g/Configurator.java Thu Jun
 7 07:37:47 2007
@@ -18,6 +18,8 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Properties;
 
@@ -87,7 +89,30 @@
 					}
 					String filename = LOCAL_ECLIPSE_CONFIG + File.separator + CONFIG_FILE;
 					File file = new File(filename);
-					file.createNewFile();
+					if (file.exists())
+					{
+						byte byteArray[] = null;
+						int filelen = (int)file.length();
+						byteArray = new byte[filelen];
+						int status = -1;
+						FileInputStream inBak = new FileInputStream(file);
+						status = inBak.read(byteArray);
+						FileWriter outBak = new FileWriter(LOCAL_ECLIPSE_CONFIG + File.separator + "config.bak");
+						String fileString = new String(byteArray);
+						outBak.write(fileString);
+						outBak.close();
+					}
+					else
+						file.createNewFile();
+					/*
+					 * Open file for read
+					 * Read properties existing from file
+					 * Close the file
+					 */
+					FileInputStream infile = new FileInputStream(file);
+					config.load(infile);
+					infile.close();
+					
 					config.setProperty(INSTALL_AREA, eclipseDir);
 					String bundles = DEFAULT_BUNDLES;
 					File pluginsDir = new File(LOCAL_ECLIPSE_PLUGINS);
@@ -98,9 +123,16 @@
 					}
 					config.setProperty(BUNDLES_KEY, bundles);
 					config.setProperty(SHARED_CONFIG, "./");
+					/*
+					 * Open file for output
+					 * Write properties to the file
+					 * Close the file
+					 */
 					FileOutputStream out = new FileOutputStream(file);
 					config.store(out, "Eclipse configuration file.");
 					out.close();
+					System.out.println("A backup of your configuration file has been written to "+LOCAL_ECLIPSE_CONFIG
+ File.separator + "config.bak");
+					System.out.println(" ");
 					System.out.println("Configuration complete.");
 				}
 				else {
@@ -116,4 +148,4 @@
 		}
 
 	}
-}
\ No newline at end of file
+}



Mime
View raw message