Delete File or Directory on Termination in Java

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

295 Views

A file or directory can be deleted on termination of the program 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) {          e.printStackTrace(); ... Read More

BigInteger isProbablePrime Method in Java

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

312 Views

TheBigInteger.isProbablePrime(int certainty) returns true if this BigInteger is probably prime, false if it's definitely composite. If certainty is ≤ 0, true is returned.Here, the “certainty” parameter is a measure of the uncertainty that the caller is willing to tolerate: if the call returns true the probability that this BigInteger is prime exceeds (1 - 1/2certainty). The execution time of this method is proportional to the value of this parameter.The following is an example −Example Live Demoimport java.math.BigInteger; public class Demo { public static void main(String[] argv) throws Exception { // create 3 ... Read More

How Constraint Layout Works in Android

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

1K+ Views

In simple words, constraint layout is an advanced version of a Relative layout. It is used to reduce the child view hierarchies and improve the performance.Properties of constraint layout as shown below -Wrap Content –It wrap the view size according to data. Any Size – This is very similar to match parent. Fixed Size – This allows standard height and width(fixed sizes). In the above example we have shown the button with all properties, now look into code level as shown below -In the above, we have declare layout margin-top, bottom, start and end. those are the standard distance (Similar ... Read More

Cancel Executing AsyncTask in Android

Chandu yadav
Updated on 30-Jul-2019 22:30:24

2K+ Views

Before getting into example, we should know what is AsyncTask in android. AsyncTask going to do operations/actions in background thread and update on mainthread. While doing background operations on background thread, user can cancel operations by using the following code -AsynTaskExample mAsyncTask = new AsyncTaskExample(); mAsyncTask.cancel(true);This example demonstrate about how to cancel an executing AsyncTask in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         In the above code when ... Read More

Job Opportunities in Software Field with Active BTech Backlog

Tejas Charukula
Updated on 30-Jul-2019 22:30:24

551 Views

It really does not matter whether you complete your B.Tech or not if you have software skills. Many companies are allowing one or two backlogs when they select the students during campus interviews.A lot of my friends who have one or two backlogs are already placed in good companies like Deloitte, Wipro, and others based on their technical knowledge by the end of 4th year, even before final exams. At the end of the day, you have to complete the graduation. But, for time being you can start working in the software field.

FTP rmdir Function in PHP

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

92 Views

The ftp_rmdir() function deletes a directory on the FTP server. Remember that the directory to be deleted should be empty.Syntaxftp_rmdir(conn,dir);Parametersconn −The FTP connectiondir − The empty directory to be deleted.ReturnThe ftp_rmdir() function returnsTRUE on success or FALSE on failure.ExampleThe following is an example −

Round a Double to BigDecimal in Java

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

421 Views

The java.math.BigDecimal class provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion.Firstly, let us pass a double to BigDecimal −BigDecimal val = new BigDecimal(9.19456);Now, we will round it −val = val.setScale(2, BigDecimal.ROUND_HALF_EVEN);Above, we have used the field ROUND_HALF_EVEN. It is a rounding mode to round towards the "nearest neighbor" unless both neighbours are equidistant, in which case, round towards the even neighboursThe following is an example −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String args[]) { BigDecimal val = new BigDecimal(9.19456); ... Read More

Group Month and Year in MySQL

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

6K+ Views

You can group month and year with the help of function DATE_FORMAT() in MySQL. The GROUP BY clause is also used.The syntax is as follows −SELECT DATE_FORMAT(yourColumnName, '%m-%Y') from yourTableName GROUP BY MONTH(yourColumnName), YEAR(yourColumnName)DESC;To understand the above concept, let us create a table. The following is the query to create a table −mysql> create table GroupMonthAndYearDemo −> ( −> DueDate datetime −> ); Query OK, 0 rows affected (1.49 sec)Insert records in the table using the following query −mysql> insert into GroupMonthAndYearDemo values(now()); Query OK, 1 row affected (0.11 sec) ... Read More

Programming the 8253

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

573 Views

According to the microprocessor point of view, the 8253 is designed and has some specialty port chip I/O. We don't use it for interfering the I/O devices. For performing the application of time it is used. 8253 has the addressed A1 and A0 input pins.The counters have width of 16 bits. If they were 8-bits wide, the delay in time that would be generated is very small. The Least Significant Byte and the Most Significant Byte of a counter is selected by using the same address of the port.The processor here writes to the control port to configure the working of ... Read More

What is the Use of the App PhonePe

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

1K+ Views

PhonePe is a very popular and useful application especially in today’s era of digitization. The app is named after Fin-Tech company, the headquarters of which are in Bangalore, India. It is quite recent, as it was found in December 2015.Uses of PhonePe1. Mobile recharge: By using this app, you can get your mobile phone recharged very easily. You simply need to mention the amount, phone number and the appropriate mobile operator's name. You can even browse plans. You don’t have to load funds into your wallet for the recharge. Rather, you can make payments from your bank account by using ... Read More

Advertisements