Created
January 22, 2018 10:41
-
-
Save smyykb/b16e5836dfd41456586dc42a6e240e85 to your computer and use it in GitHub Desktop.
EOF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
READ: | |
FileInputStream in = openFileInput("filename.txt"); | |
InputStreamReader inputStreamReader = new InputStreamReader(in); | |
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); | |
StringBuilder sb = new StringBuilder(); | |
String line; | |
while ((line = bufferedReader.readLine()) != null) { | |
sb.append(line); | |
} | |
--------- | |
WRITE: | |
FileOutputStream fos = openFileOutput(textOutput, Context.MODE_PRIVATE); | |
fos.write(textOutput.getBytes()); | |
fos.close(); | |
-------------------- | |
Storing: | |
KeyStore ks = KeyStore.getInstance("JKS"); | |
ks.setKeyEntry("keyAlias", key, passwordForKeyCharArray, certChain); | |
OutputStream writeStream = new FileOutputStream(filePathToStore); | |
ks.store(writeStream, keystorePasswordCharArray); | |
writeStream.close(); | |
Note thet certChain might be null, unless you are passing PrivateKey | |
------------- | |
Loading: | |
KeyStore ks = KeyStore.getInstance("JKS"); | |
InputStream readStream = new FileInputStream(filePathToStore); | |
ks.load(readStream, keystorePasswordCharArray); | |
Key key = ks.getKey("keyAlias", passwordForKeyCharArray); | |
readStream.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment