mkhan900
asked on
Java combine command line programs.
I found the code below to solve my problem with a command line program. But since I am very new to java I don't understand how to incorporate this code along with mine. Can some one plz help me do this.
Following is the link to the code which I am trying to incorporate with my program
http://www.javalobby.org/java/forums/t53333.html
This needs to be incorporated with the above code
import java.io.*;
import java.lang.*;
public class enCryptFiles
{
public static void main(String args[]) throws Exception
{
String Fname = new String();
String[] filenames;
File f = new File(args[0]);
filenames = f.list();
for(int i=0; i< filenames.length; i++)
{
String[] command = new String[] { "cmd","/c","start","filecr ypt ", "--encrypt "+ filenames[i] + " --user ", "PublicKey"};
for (int t=0; t<command.length; t++)
{Fname = Fname+" "+command[t];}
System.out.println(Fname);
Process p = Runtime.getRuntime().exec( Fname);
Fname = null;
} }}
Thanks
Following is the link to the code which I am trying to incorporate with my program
http://www.javalobby.org/java/forums/t53333.html
This needs to be incorporated with the above code
import java.io.*;
import java.lang.*;
public class enCryptFiles
{
public static void main(String args[]) throws Exception
{
String Fname = new String();
String[] filenames;
File f = new File(args[0]);
filenames = f.list();
for(int i=0; i< filenames.length; i++)
{
String[] command = new String[] { "cmd","/c","start","filecr
for (int t=0; t<command.length; t++)
{Fname = Fname+" "+command[t];}
System.out.println(Fname);
Process p = Runtime.getRuntime().exec(
Fname = null;
} }}
Thanks
There's lots of code at that link. What you really seem to mean is that you want your original code fixed(?)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There was very small error in my code. To find this error I thought of using the code from the link.
But I found the error.
In the loop I was only using the file name where as the Command Line program (like every program) required the absolute path along with the filename and it worked.
Thanks for your response Cehj
But I found the error.
In the loop I was only using the file name where as the Command Line program (like every program) required the absolute path along with the filename and it worked.
Thanks for your response Cehj
:-)
Does that code work properly now?
Does that code work properly now?
ASKER
Yes it does.
Thanks for the help
Thanks for the help