Well, my problem today is that when I attempt to send a String[] to the client, it won’t print out each index of the String[]
Here is what I came up with for reading a ArrayList:
public Object readObject() throws IOException, ClassNotFoundException {
Object inc = getInputStream().readObject();
if (inc instanceof ArrayList) {
ArrayList<?> list = (ArrayList<?>) inc;
int size = list.size();
System.out.println("ArrayList<?> Size: "+size);
return list;
}
return null;
}
Returns:
Now that works perfect, the client receives the ArrayList, and prints out each index correctly.
Now onto reading a String[], this is what I have so far :emo::
public Object readObject() throws IOException, ClassNotFoundException {
Object inc = getInputStream().readObject();
if (inc instanceof String[]) {
/* Create a Instance of the incoming String[] */
String[] tmp = (String[]) inc;
/* Calculate the length of the incoming String[] */
int size = tmp.length;
System.out.println("String[] Size: "+size);
String[] tmp2 = new String[size];
/* Attempt to assign each index of the incoming String[] to a new String[] for printing */
for (int i = 0; i < size; i++) {
tmp2[i] = tmp[i];
return tmp2;
}
}
return null;
}
Returns:
Please don’t post a reply relating to Serialization, for I am attempting to do this my way ;D.
Any help on this matter would be greatly appreciated.
If you notice a error in the code for reading the String[] please tell me.
Other Info:
When I highlight the block of code for reading the String[] in my IDE (Eclipse), it says “Dead Code” T_T.