in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
out = new DataOutputStream(sock.getOutputStream());
String cmd = in.readLine();
if(!cmd.contains(" ")) {
throw new PatternSyntaxException(
"command should be keyword pattern, but no ' ' seen", cmd, -1);
}
String uppercased = cmd.substring(0, cmd.indexOf(' ')).toUpperCase();
if(RAW.equals(uppercased))
fmt = DataFormat.Raw;
else if(WRITABLE.equals(uppercased))
fmt = DataFormat.Writable;
else if(ASCII_HEADER.equals(uppercased))
fmt = DataFormat.Header;
else {
throw new PatternSyntaxException("bad command '" + uppercased+
"' -- starts with neither '"+ RAW+ "' nor '"+ WRITABLE + " nor "
+ ASCII_HEADER+"'.", cmd, -1);
}
String cmdAfterSpace = cmd.substring(cmd.indexOf(' ')+1);