- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AlgorithmParameterGenerator getProvider() method in Java
The provider of the generator object can be obtained using the method getProvider() in the class java.security.AlgorithmParameterGenerator. This method requires no parameters and it returns the provider of the generator object.
A program that demonstrates this is given as follows −
Example
import java.security.*; import java.util.*; public class Demo { public static void main(String[] argv) { try { AlgorithmParameterGenerator apGenerator = AlgorithmParameterGenerator.getInstance("DiffieHellman"); apGenerator.init(1024); Provider provider = apGenerator.getProvider(); System.out.println("The Provider is: " + provider); } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } catch (ProviderException e) { System.out.println("Error!!! ProviderException"); } } }
Output
The Provider is: SunJCE version 1.8
Now let us understand the above program.
The method getProvider() is used to obtain the provider of the generator object. Then this provider is displayed. If the algorithm name is wrong, then the exception NoSuchAlgorithmException is thrown. A code snippet that demonstrates is given as follows −
try { AlgorithmParameterGenerator apGenerator = AlgorithmParameterGenerator.getInstance("DiffieHellman"); apGenerator.init(1024); Provider provider = apGenerator.getProvider(); System.out.println("The Provider is: " + provider); } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } catch (ProviderException e) { System.out.println("Error!!! ProviderException"); }
- Related Articles
- AlgorithmParameterGenerator getAlgorithm() method in Java
- AlgorithmParameterGenerator generateParameters() method in Java
- SecureRandom getProvider() method in Java
- KeyPairGenerator getProvider() method in Java
- Java Signature getProvider() method
- Java Signature getProvider() method with Examples
- Collections.replaceAll() method and List.replaceAll() method in Java
- Method overloading in Java
- Method overriding in Java
- BigInteger.isProbablePrime() method in Java
- Integer.lowestOneBit() method in Java
- Integer.numberOfLeadingZeros() method in Java
- Integer.numberOfTrailingZeros() method in Java
- Integer.rotateLeft() method in Java
- Integer.signum() method in Java

Advertisements