refs #12
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:
parent
693d5f8e9d
commit
d15ae9de9e
@ -847,7 +847,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedModule = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(),
|
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,
|
JOptionPane.QUESTION_MESSAGE,
|
||||||
null,
|
null,
|
||||||
ModuleNameList,
|
ModuleNameList,
|
||||||
|
@ -99,35 +99,38 @@ public class Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize the string s and
|
* Serialize the string data and write it to the OutputStream.
|
||||||
* store its serialized state in File with name Filename.
|
|
||||||
*
|
*
|
||||||
* @param filename The file
|
* @param outStream The output stream
|
||||||
* @param data The string data
|
* @param data The string data
|
||||||
**/
|
**/
|
||||||
public static void storeString(final OutputStream outStream, final String data) {
|
public static void storeString(final OutputStream outStream, final String data) {
|
||||||
try {
|
try {
|
||||||
store(data, outStream, false);
|
outStream.write(data.getBytes());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not write string to stream", 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.
|
* a string and return the resulting string.
|
||||||
*
|
*
|
||||||
* @param filename The file
|
* @param inputStream The input stream to read from
|
||||||
* @return The deserialized data from the file
|
* @return The deserialized data from the stream
|
||||||
**/
|
**/
|
||||||
public static String loadString(final InputStream inputStream) {
|
public static String loadString(final InputStream inputStream) {
|
||||||
String data = null;
|
StringBuilder sBuilder = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
data = (String) load(inputStream);
|
int data = inputStream.read();
|
||||||
} catch (Exception ex) {
|
while (data != -1) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not load string from file!", ex);
|
sBuilder.append((char) data);
|
||||||
|
data = inputStream.read();
|
||||||
}
|
}
|
||||||
return data;
|
} catch (Exception ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not load string from stream!", ex);
|
||||||
|
}
|
||||||
|
return sBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user