Maruthi Krishna has Published 951 Articles

How to check if String value is Boolean type in java?

Maruthi Krishna

Maruthi Krishna

Updated on 11-Oct-2019 07:00:42

10K+ Views

The Boolean class of the lang package provides two method namely parseBoolean() and valueOf().parseBoolean(String s) − This method accepts a String variable and returns boolean. If the given string value is "true" (irrespective of its case) this method returns true else, if it is null or, false or, any other ... Read More

How to execute an external program like windows media player in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 11-Oct-2019 06:56:18

792 Views

Using the Runtime classJava provides a class named java.lang.Runtime, using this class you can interface with the current environment.The getRunTime() (static) method of this class returns a Runtime object associated with the current application.The exec() method accepts a String value representing the command to execute a process in the current ... Read More

How to check that a string is parse-able to a double in java?

Maruthi Krishna

Maruthi Krishna

Updated on 11-Oct-2019 06:44:29

5K+ Views

Using the parseDouble() methodThe parseDouble() method of the java.lang.Double class accepts a String value, parses it, and returns the double value of the given String.If you pass a null value to this method, it throws a NullPointerException and if this method is not able to parse the given string into ... Read More

How to read the contents of a web page without using any external library in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 11-Oct-2019 06:38:41

271 Views

The URL class of the java.net package represents a Uniform Resource Locator which is used to point a resource (file or, directory or a reference) in the world wide web.The openStream() method of this class opens a connection to the URL represented by the current object and returns an InputStream ... Read More

How to read the contents of a webpage into a string in java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Oct-2019 13:44:14

11K+ Views

You can read the contents of a web page in several ways using Java. Here, we are going to discuss three of them.Using the openStream() methodThe URL class of the java.net package represents a Uniform Resource Locator which is used to point a resource (file or, directory or a reference) ... Read More

How to find a unique character in a string using java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Oct-2019 13:10:38

14K+ Views

You can find whether the given String contains specified character in the following ways −Using the indexOf() methodYou can search for a particular letter in a string using the indexOf() method of the String class. This method returns an integer parameter which is a position index of a word within ... Read More

Java program to check for prime and find next Prime in Java

Maruthi Krishna

Maruthi Krishna

Updated on 10-Oct-2019 11:21:16

5K+ Views

Any whole number which is greater than 1 and has only two factors that is 1 and the number itself, is called a prime number. Other than these two number it has no positive divisor. For example: 7 = 1 × 7Following is the algorithm to find whether a number ... Read More

Redirecting System.out.println() output to a file in Java

Maruthi Krishna

Maruthi Krishna

Updated on 10-Oct-2019 11:18:00

8K+ Views

The filed named out of the System class represents a standard output Stream, an object of the PrintStream class.The println() method of this accepts any a value ( of any Java valid type), prints it and terminates the line.By default, console (screen) is the standard output Stream (System.in) in Java ... Read More

Java program to delete all the files in a directory recursively (only files)

Maruthi Krishna

Maruthi Krishna

Updated on 10-Oct-2019 11:15:43

1K+ Views

Assume we have a folder named ExampleDirectory in the directory D with 7 files and 2 directories as −Where, SampleDirectory1 contains two files named SampleFile1.txt and SampleFile2.txt.SampleDirectory2 contains two files named SampleFile2.txt and SampleFile3.txt.ExampleFollowing Java example deletes all the files in the directory named ExampleDirectory.import java.io.File; import java.io.IOException; public class ... Read More

Java program to List all files in a directory recursively

Maruthi Krishna

Maruthi Krishna

Updated on 10-Oct-2019 11:12:54

4K+ Views

Assume we have a folder named ExampleDirectory in the directory D with 7 files and 2 directories as −Where, SampleDirectory1 contains two files named SampleFile1.txt and SampleFile2.txt.SampleDirectory2 contains two files named SampleFile2.txt and SampleFile3.txt.ExampleFollowing Java example lists the names of all the files in the directory named ExampleDirectory.import java.io.File; import ... Read More

Advertisements