Update Last Modified Time For File in Java Example Program
Change Last Modified Time in Java In this tutorial, we will explain how easy it is to use NIO to change last modified time information against a File in Java. We had explained earlier how to modify the date created timestamp using Java. This example can be considered as an extension of that. Current Modified TimeStamp - Input We will use the following input file and check the file ....
Java NIO Read File Metadata / Attributes Example
How to read File Metadata in Java NIO? In this example, we will explain how to use Java NIO classes, to read the following attributes / metadata of any file available in the file system. More specifically, we will discuss how to read the following metadata information against any file: Last Modified Time Last Access Time Creation Time Size of the File in bytes Is a regular File? Is the ....
Index of All Java Posts
Rename ZIP File Entries in Java using ZPFS / NIO Example Add New ZIP File Entries in Java using ZPFS / NIO Example Delete ZIP File Entries in Java using ZPFS / NIO Example Extract ZIP File in Java using ZPFS / NIO Example Create ZIP File in Java using ZPFS / NIO Example Read / Extract TAR File - Java Example Convert OutputStream to InputStream in ....
Compare two files by content - Java Example
Compare two Files - Introduction In this tutorial, we will provide a highly simplified approach to compare two files in Java by content. We will use Apache Commons IO library to perform this comparison, and run this against some test files we prepare to see the results. Make sure you download commons-io-2.4 and have the file commons-io-2.4.jar in your classpath.We will be using the class ....
How To Read Excel Files in Java
In this post we will present a working solution, that explains how to read and modify a Microsoft Excel Document in Java. The objective for us would be to read an excel file, write some data on a different column based on the input we read and modify the excel document. As an example, let us assume that we have an Excel document (ReadExcelUsingJava.xls) with the following content in column 'A'; ....
Dom4j Modify a XML file
We saw about creating a XML with DOM4J in the previous post. In this post, we will see how to modify an existing XML using DOM4J. Make sure that you have the following JAR files with you before you start: 1) dom4j-1.6.1 -> you can grab this from the official website. Check out here. 2) jaxen-1.1.1 -> This is an open source XPATH library internally used in Dom4J. Grab the ....
Java Interview Questions
Java interview questions and answers - Upload a doc Read this doc on Scribd: Java interview questions and answers ....
How to find last modified time of a file in Java?
To answer this question, it is very easy to find the last modified timestamp of a file in Java using NIO. An example code, that helps to find the last modified time of a file is provided below: import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; public class LastModifiedTime { ....
How to check if a Char is uppercase in Java?
In this quick post, we will provide a Java program using which you can check if a character is an uppercase character in Java or not. To do this, we will use Apache Commons Lang library, and you need to have a copy of the following JAR file in your classpath=> commons-lang3-3.1.jar. Java Program – Check if Character is UpperCase We will use the method isAsciiAlphaUpper, defined in ....
Java NIO Delete File Example Code Program
In this post, let us examine the various approaches that are available to delete a file in a specific folder using Java. We will see how to delete a file in Java using java.nio.file.Files class and the standard java.io.File class. At the end you will find that the NIO class offers very elegant solution to delete a file in Java. In order to get started, let us write a simple program to delete a ....
Read File Creation Time in Java Example Program
Use Java NIO to Access File Creation TimeStamp Up until now, there is no direct method in Java to write a consistent logic across different operating systems, to retrieve the file creation timestamp. There are many posts across different OS, writing their own command line approaches to read file creation time stamp. Gone are those days. Java NIO offers a very elegant way to retrieve a file ....
SVG to JPG Java Servlet Program Example
Java Servlet – SVG to JPEG In this post, we will provide a Java servlet program, that accepts an user uploaded SVG image, and returns a JPEG output, by transcoding the SVG input using Apache Batik library.We will cover the HTML form and servlet program in this article. We would also require Apache Commons library, to convert SVG to JPG, and will introduce them as we move on this tutorial. ....
Change last access time for a File in Java NIO Example
Java NIO - Change Last Access Time for File In this NIO tutorial, we will explain how to change last access time for a file, using a Java program. We earlier discussed about changing created and modified time stamps for a file. This example is based on the previous series, and hope it will be a good learning on NIO library for you. Input File The test file we will use to change last ....
Change Date Created Time for File Using Java Program NIO Example
Change Created Time Stamp for a File using Java This tutorial provides a Java example, that explains how to update the date created timestamp for a file using a Java program. By date created, we mean the following time stamp information: Change Created Time Stamp for a File Using Java Program Java NIO - Program - Example Let us now write a program that changes the Created ....
Search Word Document Using Java Example
In this tutorial, we will examine the possibility to search a Microsoft Word document for a text / pattern, using a Java program. We will use Apache POI to parse the Word document and java.util.Scanner to perform a string search, and report the number of occurrences of the input pattern as the output. This tutorial is targeted for beginners, and you can feel free to extend the code provided ....
Java NIO.2 Recursive Directory Listing Example
In this tutorial, we will teach you how to list all the directories inside a folder recursively in Java, using NIO.2. Specifically, we will look into FileVisitor interface (java.nio.file.FileVisitor) and implement the methods available in this interface, to traverse a folder. We will focus on listing the following items during our traversal in this example: List Sub directory Name List ....
Create 7z File - Java Example - LZMA Compression
In this tutorial, we will discuss how to create a 7z archive file in Java with an example program. We will use LZMA as the compression method for 7z file that provides a very high compression ratio when compared with ZIP or RAR formats. LZMA stands for Lempel-Ziv-Markov chain algorithm which is a popular for providing lossless data compression. You can download the source files for this ....
Java SHA-256 Hashing Example
In this post, we will discuss how to calculate SHA-256 checksum for a file and input string using Java with suitable examples. The input file is a ~2GB file and let us compare the execution times at the end. File Checksum with SHA-256 and FileInputStream In this example, we will use FileInputStream class with byte reads to generate the SHA hash. The Java code that does this is provided ....
Extract Database Table to XML in Java Program
In this new series of XML tutorials, we will see a very simple example in Java, that will explain how to extract XML data from Oracle database table without much coding effort. This example can be extended to support any database and is not specific to Oracle. But, you need to make sure that you use the right database drivers so that it works with your DBMS.Note that this is not the only ....
List Folder Contents in Java
Often Java Developers stumble across a simple situation and end up googling the web to find the best code which can help to solve their needs. One such situation is - How to write a simple java program that lists the contents of a folder. There are quite a lot of solutions available for this, but I would like to post a working solution which can sometime prove really handy in solving the question ....
Java JExcel Protect WorkSheet
In this post, we will see how to protect an Excel worksheet with a password using JExcel in Java with a simple example. Protecting an Excel Spreadsheet is a frequently used task and JExcel API can help to achieve this objective. It will be possible to specify a password in the code for this kind of protection. The Java code for worksheet protection is provided below (comments inline)import ....
Dom4j XML Creation
I was trying to create a XML file using Dom4j yesterday. For those, who don't know about it, here is a gentle introduction. Dom4j is a open source library to work with XML, XSLT and XPATH in Java platform. It just makes the working with XML files so easy. The official website link is here. Grab the download before you start to work with the example here. Here is a neat working example of ....
No comments:
Post a Comment