Reasons for Defect Leakage

What is the reasons for Defect Leakage? Negligence Lack of discipline Do not know what to do Lack of domain knowledge Skills Do not care about any process – will do my way Jumping into coding without think / understanding the…

JUnit Principles – Write tests first

JUnit Principles – Write tests first Unit testing is intended to validate that a class and its methods do what the developer intended them to do. Unit tests are not intended to replace functional or…

Java Code Refactoring Tasks

Code Smells – Java Code Refactoring Tasks Insufficient Tests How many tests should be in a test suite? Unfortunately, the metric many programmers use is “That seems like enough.” A test suite should test everything that could possibly…

Get Total or Free Disk Space In JavaIO

Get Total or Free Disk Space In JavaIO   Problem Statement: How to Get Total or Free Disk Space In JavaIO? Description: We can get the total or free disk space using  java.io.File.getTotalSpace(),  java.io.File.getUsableSpace(),  java.io.File.getFreeSpace() The java.io.File.getTotalSpace() returns the number…

Find last modified time of a File in Java

Problem Statement: How to find last modified time of a File in Java? Description To find last modified time of a file in java, we have to use File.lastModified() method of File class passing the new instance of file pathname…

Delete File – Java IO File.delete()

Problem Statement: How to Delete File in Java? Description To delete file in java, we have to use File.delete() method of File class passing the new instance of file pathname as shown below.  This method returns true if delete operation is…

Rename File in Java – File.renameTo()

Problem Statement: How to Rename File in Java? Description Rename file in java is very simple using Java IO API. We have to use renameTo() of File class passing the new instance of file as shown below. Note…

Construct File Path In Java

Construct File Path In Java

Construct File Path In Java Problem statement: How to construct file path in Java IO? Description To construct file path using Java IO classes like  File.separator, File.createNewFile. Code package com.stixs.java.io; import java.io.File; import java.io.IOException; public class STXCreateFilePath { public static void…

Create File using Java IO (With Examples)

Java Create new File in Java - IO Exception

How to Create File using Java IO? Problem Statement How to create file using Java IO? Description To create file using Java IO, we can use api – File.createNewFile(). This method returns a boolean value true if the file is…

Java Util – Date example with formatter

DateFormat

Java Util – Date example with formatter Problem Statement: Java code to print the date and/or time in a locale-sensitive or otherwise-specified format. Solution/ Answer: Use java.text.DateFormat.   Discussion To print the date in the correct format for the specified locale use Java Util and…