Java Program to delete a file or directory when the program ends

Samual Sam
Updated on 30-Jul-2019 22:30:24

131 Views

A file or directory with the required abstract pathname can be deleted when the program ends i.e. after the virtual machine terminates using the method java.io.File.deleteOnExit(). This method requires no parameters and it does not return a value.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       try {          File file = new File("demo1.txt");          file.createNewFile();          System.out.println("File: " + file);          file.deleteOnExit();       } catch(Exception e) {   ... Read More

Which is the best Search Engine?

yashwanth sitamraju
Updated on 30-Jul-2019 22:30:24

160 Views

Being techy, I have tried almost all the existing search engines up till now and finally, I have come to the conclusion that Google stands way above than the rest at least for the time being. Know exactly why?Google search engine uses a powerful tool to filter your search. Without Google, it is practically impossible to find information based on your need.Google uses a special algorithm to generate results and however, it shares the general information and facts about its algorithm but the specifics are confidential and are a company secret.Google uses automated programs named Spider or Crawler and what ... Read More

How to store Query Result in a variable using MySQL?

Anvi Jain
Updated on 30-Jul-2019 22:30:24

7K+ Views

To store query result in a variable with MySQL, use the SET command. The syntax is as follows −SET @anyVariableName = ( yourQuery);To understand the above concept, let us create a table. The following is the query to create a table −mysql> create table QueryResultDemo    −> (    −> Price int    −> ); Query OK, 0 rows affected (0.59 sec)Now let us insert some records into the table. The following is the query to insert records −mysql> insert into QueryResultDemo values(100); Query OK, 1 row affected (0.17 sec) mysql> insert into QueryResultDemo values(20); Query OK, 1 row ... Read More

Java Program to remove a key from a HashMap only if it is associated with a given value

Samual Sam
Updated on 30-Jul-2019 22:30:24

72 Views

Use the remove() method to remove a key only if it is associated with a given value.Let’s say the following is our HashMap −// Create a hash map HashMap hm = new HashMap(); // Put elements to the map hm.put("Bag", new Integer(1100)); hm.put("Sunglasses", new Integer(2000)); hm.put("Frames", new Integer(800)); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));Here, we are removing a key “Belt” only if it is associated with the given value 600 −hm.remove("Belt", 600);The following is an example to remove a key only if it is associated with a given value −Example Live Demoimport java.util.*; public class Demo {    public static void ... Read More

Who is the pioneer person behind Aditya Birla Group?

Knowledge base
Updated on 30-Jul-2019 22:30:24

138 Views

Birla is one of the names which needs no introduction in India. Birla, the brand name of a number of products, is the family name of a Marwari family which hails from Rajasthan. Besides being the largest business tycoons, they are into several social activities also. From the highly reputed institutes like BITS and Birla Schools to the Birla temples constructed all over India, their contribution is in many sectors in India.Aditya Birla GroupThe founder of Aditya Birla Group was Shri Seth Shiv Narayan Birla in 1857. This is an Indian multinational conglomerate that operates in 40 countries having interests ... Read More

When was the word Hindu used for the first time?

Knowledge base
Updated on 30-Jul-2019 22:30:24

2K+ Views

Hindu or Indu is the word, derived from the river Indus, which flows in the North-western part of India. The Greeks used to mention the people beyond this river as “Indu”s, naming after the Indus river. As this Indus river is locally called as Sindhu, the people were also called as Sindhus.The OriginHowever, the Arabic people used to call the people beyond the Indus river as “Al-Hind” which was later turned to be “Hind”s or Hindus. The land of Hindus was called as Hindustan, which later on became India, probably after the British invasion.The civilization surrounding this river is also ... Read More

Why should we do our duty but leave the result to god?

Knowledge base
Updated on 30-Jul-2019 22:30:24

141 Views

God is believed to be a supreme entity who is omnipresent, omnipotent, omniscience and benevolent. Actually, it is a simple scientific and psychological thinking that if you have somebody to look after you, then you need not worry about your responsibilities. But of course, you should fulfill your responsibilities.Let me explain in simpler terms. When a boy goes to the beach to play unknowing of any hidden dangers though, the father who is watching gives an assurance to the child that he will take care of serious peril. If the child falls off while running or if his sand castles ... Read More

Do they have the word "dictionary" in the dictionary?

Jaya P
Updated on 30-Jul-2019 22:30:24

391 Views

Yes. We can find the word dictionary in a dictionary. When I referred to the Oxford Dictionary, I came across the following meaning.Dictionary: A book or electronic resource that lists the words of a language (typically in alphabetical order) and gives their meaning, or gives the equivalent words in a different language, often also providing information about pronunciation, origin, and usage.Usage:-- ‘I'll look up 'love' in the dictionary’-- ‘the website gives access to an online dictionary’

Has intolerance really spread in India?

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

39 Views

The dictionary meaning of Intolerance is “unwillingness to accept views, beliefs, or behavior that differs from one's own”.India, the so-called “Sone ki Chidiya” is now a land of controversies coming up every now and then even on a trivial matter. Many of them are spread just to get the limelight while the rest to actually show discontentment or public envy of some sort. Atrocities against minority and Dalit citizens have become frighteningly commonplace.The Responsibility of Our IconsAbout a year ago or so, Actor Aamir Khan was trolled for putting his opinion over "rising intolerance" in India, saying his wife Kiran ... Read More

Java Program to create a file and sets it to read-only

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

72 Views

A file can be set to read-only by using the method java.io.File.setReadOnly(). This method requires no parameters and it returns true if the file is set to read-only and false otherwise. The method java.io.File.canWrite() is used to check whether the file can be written to in Java and if not, then the file is confirmed to be read-only.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       boolean flag;       try {          File file = new File("demo1.txt");   ... Read More

Advertisements