[Zerofile-svn] SF.net SVN: zerofile: [34] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <el...@us...> - 2007-11-07 13:52:04
|
Revision: 34
http://zerofile.svn.sourceforge.net/zerofile/?rev=34&view=rev
Author: elpedr0
Date: 2007-11-07 05:51:57 -0800 (Wed, 07 Nov 2007)
Log Message:
-----------
Added at test save/load.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileSettings.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-07 10:45:23 UTC (rev 33)
+++ trunk/src/ZeroFile.java 2007-11-07 13:51:57 UTC (rev 34)
@@ -1,3 +1,5 @@
+import java.io.IOException;
+
//import java.net.ServerSocket;
public class ZeroFile {
@@ -3,8 +5,11 @@
/**
* @param name - The service name used by the registration class. Deprecated. Don't use.
+ * @throws IOException
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
ZeroFileMainWindow.startMainWindow();
ZeroFileChatWindow.startChatWindow();
+ ZeroFileSettings.saveSettings();
+ ZeroFileSettings.loadSettings();
try
{
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-07 10:45:23 UTC (rev 33)
+++ trunk/src/ZeroFileSettings.java 2007-11-07 13:51:57 UTC (rev 34)
@@ -1,6 +1,9 @@
/* Settings for the program are stored in this class. Or something.
* At present, all it holds are a bunch of getters and setters.
*/
+import java.util.*;
+import java.io.*;
+
public class ZeroFileSettings {
private static String _nickName;
private static String _firstName;
@@ -8,6 +11,26 @@
private static String _email;
private static int _mainPort;
+ /*public static void saveSettings() throws IOException
+ {
+ // set up default properties
+ Properties defaultProps = new Properties();
+ FileInputStream defaultStream = new FileInputStream("defaultProperties");
+ defaultProps.load(defaultStream);
+ defaultStream.close();
+
+ // set up real properties
+ Properties applicationProps = new Properties(defaultProps);
+ FileOutputStream appStream = new FileOutputStream("appProperties");
+
+
+ applicationProps.put ( "HEIGHT","300" ) ;
+ applicationProps.put ( "WIDTH","300" ) ;
+
+
+ }*/
+
+
public static String getNickName()
{
return _nickName;
@@ -57,4 +80,27 @@
{
_mainPort = p;
}
+
+ public static void saveSettings() throws IOException {
+
+ Properties applicationProps = new Properties();
+ FileOutputStream appStream = new FileOutputStream("appProperties");
+ applicationProps.put("first", "balle");
+ applicationProps.put("last", "ballesson");
+ applicationProps.save(appStream, "settings");
+ appStream.close();
+ }
+
+ public static void loadSettings() throws IOException {
+ Properties applicationProps = new Properties();
+ FileInputStream appStream = new FileInputStream("appProperties");
+ applicationProps.load(appStream);
+ String key = "last";
+ String val = applicationProps.getProperty ( key ) ;
+ System.out.println ( val ) ;
+ appStream.close();
+
+ }
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|