java - How to pass args when calling one method from another -


i have written following code create key pair, store private key locally, , read private key file.

when try call methods saveprivatekey(); , retrieveprivatekey(); testdata(view view) error says (string[]) cannot applied (). want able call both of above mentioned functions in testdata(view view);

public class encryptionactivity extends actionbaractivity { private static final string tag = encryptionactivity.class.getsimplename();  textview textpublickey; textview textprivatekey; button buttontest; textview privatekey; integer n; string filename = "privatekey";   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_encryption);      // output keys screen     textprivatekey = (textview)findviewbyid(r.id.textprivatekey);     textprivatekey.setmovementmethod(new scrollingmovementmethod());     // textpublickey = (textview)findviewbyid(r.id.textpublickey); }  private void asymmetricalgorithmrsa() {     // generate key pair 1024-bit rsa encryption , decryption     key publickey = null;     key privatekey = null;     try {         keypairgenerator kpg = keypairgenerator.getinstance("rsa");         kpg.initialize(1024);         keypair kp = kpg.genkeypair();         publickey = kp.getpublic();         privatekey = kp.getprivate();     } catch (exception e) {         log.e(tag, "rsa key pair error");     }      //textpublickey.settext(string.valueof(publickey));     //textprivatekey.settext(string.valueof(privatekey));  }  public void saveprivatekey(string[] args) throws filenotfoundexception {     try {         // store private key locally         string string = string.valueof(privatekey);          fileoutputstream fos = openfileoutput(filename, context.mode_private);         fos.write(string.getbytes());         fos.close();     }     catch (exception e) {         log.e(tag, "error saving file.");     } }  public void retrieveprivatekey(string[] args) throws filenotfoundexception {     try {         fileinputstream fis = openfileinput(filename);         stringbuffer filecontent = new stringbuffer("");          byte[] buffer = new byte[1024];          while ((n = fis.read(buffer)) != -1) ;         {             filecontent.append(new string(buffer, 0, n));         }          textprivatekey.settext(string.valueof(filecontent));     }     catch(ioexception e) {             log.e(tag, "error opening file.");         } }  public void testdata(view view){      asymmetricalgorithmrsa();     saveprivatekey();     retrieveprivatekey(); } 

both saveprivatekey , retrieveprivatekey accept string[], although not use them. drop these redundant parameter specifications , should fine:

public void saveprivatekey() throws filenotfoundexception {     // code here... }  public void retrieveprivatekey() throws filenotfoundexception {     // code here... } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -