I would like to call the Java class file from compiling the following code:
import java.io.*;
public class hex_to_dec {
private BufferedReader bufferedReader;
private BufferedWriter bufferedWriter;
public hex_to_dec (String stringPath, String stringPath_dec)
{
try
{
bufferedReader = new BufferedReader(new FileReader(stringPath));
bufferedWriter = new BufferedWriter(new FileWriter(stringPath_dec, false));
} catch (Exception e) {
System.out.println("Error in opening file." + e);
}
}
public void Parse()
{
try {
String tempLine;
int temp;
while((tempLine = bufferedReader.readLine()) != null) {
String[] tempBytes = tempLine.split(" ");
temp = Integer.valueOf(tempBytes[0], 16);
tempBytes[0] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[2], 16);
tempBytes[2] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[3], 16);
tempBytes[3] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[5], 16);
tempBytes[5] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[6], 16);
tempBytes[6] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[8], 16);
tempBytes[8] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[9], 16);
tempBytes[9] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[11], 16);
tempBytes[11] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[12], 16);
tempBytes[12] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[14], 16);
tempBytes[14] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[15], 16);
tempBytes[15] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[17], 16);
tempBytes[17] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[18], 16);
tempBytes[18] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[20], 16);
tempBytes[20] = String.valueOf(((byte) temp));
temp = Integer.valueOf(tempBytes[21], 16);
tempBytes[21] = String.valueOf((temp));
temp = Integer.valueOf(tempBytes[23], 16);
tempBytes[23] = String.valueOf(((byte) temp));
for (int i = 0; i < tempBytes.length; i++)
{
bufferedWriter.append(tempBytes[i] + " ");
}
bufferedWriter.append("\n");
}
bufferedWriter.flush();
} catch (Exception e) {
System.err.println("Error:" + e);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
hex_to_dec data = new hex_to_dec(
"C:\\Documents and Settings\\Admin\\My Documents\\MATLAB\\tests\\rssi_2\\trimmed\\s5_node12",
"C:\\Documents and Settings\\Admin\\My Documents\\MATLAB\\tests\\rssi_2\\trimmed_dec\\s5_node12");
data.Parse();
}
}
However, it requires an argument, and I don't know how to pass arguments into calling this command cleaning in bash. Also, I would like to be able to parse through a directory to call this function recursively through all the text files under the subdirectories of a selected directory. What's the easiest way of achieving this?
Thanks in advance! Hope this is not too demanding.