~ubuntu-branches/ubuntu/utopic/jcsp/utopic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class GenerateBatchFiles {

	public static void main(String[] args) {
		try
		{
			BufferedReader br = new BufferedReader(new FileReader(args[0]));
			
			String line;
			while (null != (line = br.readLine()))
			{
				line = line.trim();
				
				if (line.length() > 0)
				{
				
					final String demosPkg = "org.jcsp.demos.";
					String batchName;
					if (line.startsWith(demosPkg))
					{
						batchName = line.substring(demosPkg.length());
					}
					else
					{
						batchName = line;
					}
					batchName = batchName.replace('.','_') + ".bat";
					
					FileWriter out = new FileWriter(batchName);
					out.write("java -classpath \"jcsp-demos.jar;jcsp-demos-util.jar;jcsp.jar\" " + line + "\r\n");
					out.close();
				}
			}
			
			br.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

}