I’m currently trying to make an application which could digitally sign any kind of document. I have declared the class GenSig according to this tutorial. However in my application there should be GUI for a file input. So I have;
File file = jFileChooser2.getSelectedFile();
FileInputStream fin = new FileInputStream(file);
byte fileContent[] = new byte[(int)file.length()];
fin.read(fileContent);
String strFileContent = new String(fileContent);
GenSig gensig = new GenSig();
GenSig.main(strFileContent);
It’s throwing me an error on line GenSig.main(strFileContent); Where the variable should be String[] args according to whole source of GenSig class so I can’t compile the application. I assume that the problem is in the type of string, it’s not array, but I don’t know which array, which variable from File object, I’ve declared on firts line, I need to use as input.
I know I’m doing something wrong, unfortunately in Java I’m just beginner so I need help a bit.
-
What variable from file object should I insert as input for GenSig class?
-
Is there any easier way how to sign documents in Java?
If you are following the tutorial to the letter then you should be passing the name of the file to be ‘signed’, as an argument:
Note, you don’t actually need to create an instance of your
GenSigclass, since you are calling the main method statically.