read from csv and run

I have:

-a CSV file which contains (ID;0001;ok)

-a Program which name is 0001.qft

-a Bachfile that runs the 0001.qft

Now, I want to know: can I use JAVA to write a program which read the file name from the csv file, put it in the Batchfile and run the bachfile?

[294 byte] By [ghma] at [2007-11-27 10:55:55]
# 1

> Now, I want to know: can I use JAVA to write a

> program which read the file name from the csv file,

> put it in the Batchfile and run the bachfile?

Sure.

Look at process builder, and how to execute your batch files (likely with something like

cmd /c <file> in windows

and

/bin/sh -c <file>

in Unixland. (Note: Arguments might not be correct)

mlka at 2007-7-29 11:59:43 > top of Java-index,Java Essentials,New To Java...
# 2

Here's a demo. A file is opened with the default editor of OS.

try {

//The file name to open

String fileName = "test.txt";

URL url = getClass().getResource(fileName);

File file = new File(url.getFile());

File folder = file.getParentFile();

ProcessBuilder builder = new ProcessBuilder();

builder.directory(folder);

builder.command("cmd", "/c", fileName);

builder.start();

} catch (Exception e) {

e.printStackTrace();

}

haishaia at 2007-7-29 11:59:43 > top of Java-index,Java Essentials,New To Java...