Small code fixes and proper test implementation. Serializer does now store a string as a string and does not convert it into an object.
This commit is contained in:
Fabian Becker 2012-04-26 15:15:46 +00:00
parent 693d5f8e9d
commit d15ae9de9e
2 changed files with 17 additions and 13 deletions

View File

@ -847,7 +847,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
}
selectedModule = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(),
"Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?", "Load optimization module on host",
"Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?",
"Load optimization module on host",
JOptionPane.QUESTION_MESSAGE,
null,
ModuleNameList,

View File

@ -99,35 +99,38 @@ public class Serializer {
}
/**
* Serialize the string s and
* store its serialized state in File with name Filename.
*
* @param filename The file
* Serialize the string data and write it to the OutputStream.
*
* @param outStream The output stream
* @param data The string data
**/
public static void storeString(final OutputStream outStream, final String data) {
try {
store(data, outStream, false);
outStream.write(data.getBytes());
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not write string to stream", ex);
}
}
/**
* Deserialize the contents of File filename containing
* Deserialize the contents of the InputStream containing
* a string and return the resulting string.
*
* @param filename The file
* @return The deserialized data from the file
* @param inputStream The input stream to read from
* @return The deserialized data from the stream
**/
public static String loadString(final InputStream inputStream) {
String data = null;
StringBuilder sBuilder = new StringBuilder();
try {
data = (String) load(inputStream);
int data = inputStream.read();
while (data != -1) {
sBuilder.append((char) data);
data = inputStream.read();
}
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Could not load string from file!", ex);
LOGGER.log(Level.SEVERE, "Could not load string from stream!", ex);
}
return data;
return sBuilder.toString();
}
/**