try { // Open or create the output file FileOutputStream os = new FileOutputStream(this.clustalOutputFile); FileDescriptor fd = os.getFD(); if (this.process != null) { this.process.getInputStream().close(); this.process.getOutputStream().close(); this.process.destroy(); } this.process = Runtime.getRuntime().exec(cmdarray); // Flush the data from the streams and writers into system buffers. // The data may or may not be written to disk. os.flush(); this.process.getOutputStream().close(); // Block until the system buffers have been written to disk. // After this method returns, the data is guaranteed to have // been written to disk. fd.sync(); } catch (Exception e) { e.printStackTrace(); }