• 23 March

    Python write to text file

    In this post, we will see how to write to a text file. There are multiple modes in which you can write to text file. [toc] Create txt file(‘x’) It will open the file in 'X' mode which will create new file and return error in case file already exists. fruitsStr = ' Apple \n […]

  • 23 March

    Read File Into String in Python

    1. Introduction to the Problem Statement When working with file operations in Python, a common requirement is to read the contents of a file into a string. This can be essential for various applications, such as data processing, text analysis, or just simple file manipulation. For instance, if we have a file named example.txt with […]

  • 23 March

    Get current timestamp in java

    In this post, we will see how to get current timestamp in java. There are multiple ways to get current timestamp in java. [toc] Using Java 8’s Instant class There are three ways to get timestamp using Java 8‘s java.time.Instant class. Using Instant.now() // get current instant Instant instanceNow1 = Instant.now(); Using date.toInstant() Date date=new […]

  • 22 March

    XOR operator in java

    In this tutorial, we will see about XOR operator in java. XOR operator or exclusive OR takes two boolean operands and returns true if two boolean operands are different. XOR operator can be used when both the boolean conditions can’t be true simultaneously. Here is truth table for XOR operator. [table id=20 /] Let’s say […]

  • 22 March

    [Fixed] insert dimensions to complete referencetype

    In this post, we will see about error insert dimensions to complete referencetype. You will get this error when you are trying to pass primitive objects into generic type declaration but generic always expect a Wrapper class in java. For example: Let’s say you have the below class named InsertDimensionlMain.java. package org.arpit.java2blog; public class InsertDimensionlMain […]

  • 21 March

    Java isNull method

    In this post, we will about Objects class’s isNull method. Objects’s isNull() method is used to check if object is null or not. java.util.Objects class was introduced in java 7. Here is simple example for Object's isNull method. package org.arpit.java2blog; import java.util.Objects; public class ObjectsIsNullMain { public static void main(String[] args) { String str1="Java2blog"; String […]

  • 21 March

    Install Maven on Mac

    In this post, we will see how to install maven on Mac. [toc] If you are using the latest MacOSX, maven may be built-in and can be found at /usr/share/maven. Execute below command on terminal to see if you have maven installed. $mvn –version -bash: mvn: command not found If you get -bash: mvn: command […]

  • 21 March

    Run single test in maven

    In this post, we will see how to run single test in maven. If you want to execute all the Junit testcases in maven. You can run it below command. Run all testcase mvn test You need to go to the project location which contains pom.xml and execute above command. Run all testcases from a […]

  • 21 March

    Skip tests in maven

    In this tutorial, we will see how to skip tests in maven. It is not a good idea to skip junit tests while building project in maven but sometimes, you may need to skip it for building new code and want to test it quickly. For example: In a large project, where you have more […]

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.