Posts

Showing posts with the label Java for QA

How to handle files in Java for QA Engineers

Image
As a QA Engineer, especially when dealing with automation using Java, it's essential to understand how file handling works. Whether it’s reading a test data file, logging test results, or writing reports — **basic file operations** are a part of real-time QA work. In this blog post, you will learn: - How to create , write , read , and delete a file in Java - How to read/write Excel files using Apache POI - Real-world QA scenarios where file handling is useful - Some practice questions to boost your understanding 📂 1. Creating a File in Java You can create a new file using the File class. import java.io.File; public class CreateFile { public static void main(String[] args) { try { File file = new File("testdata.txt"); if (file.createNewFile()) { System.out.println("File created: " + file.getName()); } else { System.out.println("File already exists."); } } catch (Exceptio...

Master Java Strings for QA Engineers: A Practical Guide

Image
String is a data type in Java which stores sequence of character enclosed by double quotes.. Whether it's verifying APIs, validating UI data, or database testing, QA engineers frequently work with strings. It is also one of the important topic which generally asked in interviews. Let's break it down step-by-step! 🔹What is a String in Java? A String is a sequence of characters enclosed within double quotes (""). Java provides a robust and flexible API for handling strings, allowing for various operations such as concatenation, comparison, and manipulation. In Java, String is a class present in the java.lang package. String str = "Hello World"; Internally, Java strings are backed by a character array ( char[] ). 🔹Types of String Declaration There are two ways to create a string in Java ✅ 1. String Literal When a string is created using double quotes, Java checks the string pool first. If it already exists, it reuses the object. Str...