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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing to a specific printer tray (HP 806dn printer) 3 83
Eclipse Neon and jdk 1.8.0 11 138
Java SE 8u111  Lot of stuff broke 11 54
hibernate jars 4 4
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

867 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

21 Experts available now in Live!

Get 1:1 Help Now