Java Program to Count number of lines present in the file In this example, we will learn to count the number of lines present in a file in Java. Example 1: Java program to count the number of lines in a file using Scanner class import java.io.File; import java.util.Scanner; class Main{ public static void main(String[] …
Month: May 2021
Java Program to Get the relative path from two absolute paths In this example, we will learn to get the relative path from two absolute paths in Java using String methods, URI class, and java.nio.file package. Example 1: Get a relative path from two absolute paths using URI class import java.io.File; import java.net.URI; class Main{ …
Java Program to Get the name of the file from the absolute path In this example, we will learn to get the name of the file from the absolute path in Java. Example 1: Get file name from the absolute path using getName() import java.io.File; class Main{ public static void main(String[] args){ // link to …