Fix NOT FOUND

pull/1/head
Louis Royer 5 years ago
parent f1013e4042
commit 72ce99fd6f

@ -78,18 +78,22 @@ public class ClientManagementUDP implements Runnable {
try {
String r[] = response.split("\n", 3);
checkProtocolID(r[0]);
String r2[] = r[1].split(" ");
if (r2[0] != "LOAD") {
String r2[] = r[1].split("\n");
switch (r2[0]) {
case "LOAD":
int size = Integer.parseInt(r2[1]);
if (r[2].length() != size) {
throw new TransmissionError();
}
FileWriter fileWriter = new FileWriter(baseDirectory + filename);
fileWriter.write(r[2]);
fileWriter.close();
break;
case "NOT FOUND":
throw new NotFound();
default:
throw new ProtocolError();
}
int size = Integer.parseInt(r2[1]);
if (r[2].length() != size) {
throw new TransmissionError();
}
FileWriter fileWriter = new FileWriter(baseDirectory + filename);
fileWriter.write(r[2]);
fileWriter.close();
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
throw new ProtocolError();
} catch (NumberFormatException e) {
@ -113,7 +117,7 @@ public class ClientManagementUDP implements Runnable {
try {
String r[] = response.split("\n");
checkProtocolID(r[0]);
return response.split(protocolID + "\nLIST\n")[1];
return response.split(protocolID + "\nLIST\n")[1].split("\n\n")[0];
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
throw new ProtocolError();
}

Loading…
Cancel
Save