Tuesday, April 28, 2020

7 Examples to Read File into a byte array in Java

Java programmers often face scenarios in real-world programming, where they need to load data from a file into a byte array, it could be text or binary file. One example is to convert the contents of a file into String for display. Unfortunately, Java’s File class, which is...

Monday, April 27, 2020

JVM

How to process images and videos within Java JVM

Processing of images – let alone videos – within the Java JVM has always been a challenging task. ImageIO classes have come a long way since JDK7 – together with the usual SDK bugs – not always giving you what you expect (bad image quality, not always supporting...

Saturday, April 25, 2020

How To Validate Phone Numbers in Java (Regular Expression + Google libphonenumber)

A quick guide to how to validate phone numbers in java for different countries such as the USA, IN. Example programs with Regular Expression and Google libphonenumber API. 1. Introduction In this tutorial, We’ll learn how to validate phone numbers in java. This is to validate mainly the...

Friday, April 24, 2020

How to check if a File exists in Java with Example

Hello guys,  if you are working in Java for a couple of years then you have come across a scenario where you need to check if a file exists or not. This is often required while writing defensive code that writes or read from a file. While there...

Thursday, April 23, 2020

How to Create File and Directory in Java with Example

Many beginners confused with the fact that same class java.io.File is used to create both file and directory in Java. I agree, this is not very intuitive and  junior developers probably start looking for a class called java.io.Directory, which doesn't exists. On the other hand, creating file and...

Wednesday, April 22, 2020

2 Ways to Read a Text File in Java - Examples

You can read a text file in Java 6 by using BufferedReader or Scanner class. Both classes provide convenient methods to read a text file line by line e.g. Scanner provides nextLine() method and BufferedReader provides readLine() method. If you are reading a binary file, you can use...

Monday, April 20, 2020

Java 9 - Overview

JAVA 9 (aka jdk 1.9) is a major release of JAVA programming language development. Its initial version was released on 21 Sep 2017. The main goals of Java 9 release are − ◉ To make JDK and Java Standard Edition platform modular based in the sense that it...

Sunday, April 19, 2020

How to recursive copy directory in Java with sub-directories and file

Hello guys, it's a common requirement in Java to copy a whole directory with sub-directories and files but it's not that straight forward, especially not until Java 7. JDK 7 introduced some new file utility methods as part of Java NIO 2 which we will use in this...

Pages (26)1234567 »