Java Key Create getKeyFromFile(String keyFile)

Here you can find the source of getKeyFromFile(String keyFile)

Description

get Key From File

License

Apache License

Declaration

public static Key getKeyFromFile(String keyFile) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.FileInputStream;

import java.io.InputStream;
import java.io.ObjectInputStream;

import java.security.Key;

public class Main {

    public static Key getKeyFromFile(String keyFile) {
        Key kp = null;/*from   w ww. ja  va 2 s .  co  m*/
        try {
            InputStream is = new FileInputStream(keyFile);
            ObjectInputStream oos = new ObjectInputStream(is);
            kp = (Key) oos.readObject();
            oos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return kp;
    }
}

Related

  1. getKeyFactory()
  2. getKeyFactory(final String algorithm)
  3. getKeyFactory(final String algorithm)
  4. getKeyFactory(String keyType)
  5. getKeyFromFile(String _sFilename, String _sPassword)
  6. getKeyGenerator(String algorithm)
  7. getKeyKeyManagerFactory(InputStream keyStore, String password, String algorithm, String keyStoreType)
  8. getKeyKeyManagerFactoryByPfx(InputStream keyStore, String password)
  9. getKeyManager(KeyStore keyStore, char[] keyStorePassword)