Runtime.getRuntime().exec(cmdArray) is not properly moving all files

Posted on 2009-06-30
Last Modified: 2012-05-07
I am running the following code, but it always moves exactly 6 files, no matter what files I put into the incoming directory, leaving the rest of the files behind and indicating that the process is still running.

What could be a possible reason for this?
package com.hsc.underwriting.test;
import org.junit.Test;
public class IOTest {
	public final void testAutoMove() {
		try {
			String[] cmdArray = new String[5];
			cmdArray[0] = "cmd.exe";
			cmdArray[1] = "/C";
			cmdArray[2] = "move";
			cmdArray[3] = "incoming\\**";
			cmdArray[4] = "outgoing\\";
			Process autoMoveProcess = Runtime.getRuntime().exec(cmdArray);
		} catch (Exception e) {
			// TODO: handle exception

Open in new window

Question by:aturetsky
  • 2
LVL 86

Accepted Solution

CEHJ earned 500 total points
ID: 24750174
That will produce output that you need to consume on separate threads. See
LVL 92

Expert Comment

ID: 24750370
Is the process completing?  If not, try this:


Author Comment

ID: 24750393
CEHJ, the solution they provided worked great.  Thanks !!!!!!!!!!!!!!
LVL 86

Expert Comment

ID: 24750406

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse digits of a number using for loop 5 40
tomcat not starting 6 45
hibernate jars 4 26
How to convert from xls to xlsx using java 7 34
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now