Tagged: #java-io

How to write to a plain text file in Java

This tutorial shows several ways to write content to a text file in Java. The techniques used below are pure JDK and don’t use external libraries. 1- BufferedWriter The most common and efficient way to write content to a file in Java is through using BufferedWriter as the following:

This technique is very efficient for writing huge data to...

Java IO: difference between absolute,relative and canonical path

The common way of accessing the file system in java is through the java.io.File API. In this tutorial, we explain how to use the File API to access a file using absolute and relative paths, we also describe the difference between getPath(), getAbsolutePath() and getCanonicalPath() methods provided by the API. 1. Absolute vs Relative In general, a path is a way...