/** * Serialise this command to a stream. This data may be used to construct another {@link Command} * (see the constructors). * * @param dout output stream to write command data to * @throws IOException on any error */ public void write(DataOutputStream dout) throws IOException { dout.writeInt(arguments.size()); for (String s : arguments) { dout.writeUTF(s); } dout.writeUTF(directory == null ? System.getProperty("user.dir") : directory.getAbsolutePath()); dout.writeBoolean(redirectError); dout.writeBoolean(environment != null); if (environment != null) { dout.writeInt(environment.size()); for (Map.Entry<String, String> en : environment.entrySet()) { dout.writeUTF(en.getKey()); dout.writeUTF(en.getValue()); } } dout.writeUTF(runAs == null ? "" : runAs); dout.writeUTF(io.name()); dout.writeUTF(priority == null ? "" : priority.name()); }