Found 3 Articles for Java.IO Package

Java Program to Convert a String into the InputStream

Shriansh Kumar
Updated on 30-May-2025 17:14:32

2K+ Views

To convert a given string into an InputStream, Java provides the ByteArrayInputStream class that is used along with a built-in method named getBytes(). While displaying a long input string, we are sometimes required to process it in smaller units. At that time, converting that string into an InputStream will be helpful. In this article, we will learn how we can use the ByteArrayInputStream class to convert a string into an InputStream with the help of example programs. Before discussing that, we need to learn about the InputStream and BufferedReader classes and the getBytes() method first: InputStream Class There are two fundamental ... Read More

Smith Numbers in java

Chandu yadav
Updated on 25-Jun-2020 12:19:59

1K+ Views

A composite number whose sum of digits equal to the sum of the digits of its prime factors.Ex: 58 = 2 x 29 (5 + 8 = 12) (2+ 2 + 9 = 12)Programpublic class SmithNumbers {    public static boolean isPrime(int number) {       int loop;       int prime = 1;       for(loop = 2; loop < number; loop++) {          if((number % loop) == 0) {             prime = 0;          }       }       if (prime ... Read More

Prime factors in java

Arjun Thakur
Updated on 06-Nov-2023 03:33:46

37K+ Views

Factors are the numbers we multiply to get another number.factors of 14 are 2 and 7, because 2 × 7 = 14.Some numbers can be factored in more than one way.16 can be factored as 1 × 16, 2 × 8, or 4 × 4.A number that can only be factored as 1 times itself is called a prime number.The first few primes are 2, 3, 5, 7, 11, and 13.The list of all the prime-number factors of a given number is the prime factors of a number. The factorization of a number into its prime factors and expression of ... Read More

1
Advertisements