Basic File Manipulation With Java

Accessing files with Java is easy. With this easy to follow tutorial you will learn how to perform basic file operations in Java. Reading, writing, appending, and random file access are covered. Along with an introduction to file locking.

Sponsored Links:

Related Topics

Java Configuration File API
This is a simple Java Configuration file API. It provides methods for reading key-value pairs from a file. The main benefit over using Java's standard Properties class is support for nested array configuration values. This implementation is inspired by, but somewhat more basic than libconfig, a very useful C/C++ Configuration File Library.


How to Create File and Directory
In this Java File Tutorial we will basics of File and Directory in Java, How to Create File and Directory in Java, Utility methods provided by File API and Common Exception or Error you will face during File and Directory Creation or access time. Creating File is different than creating Thread in java as you don't have to implement any interface for making a Class as File in Java.


String Manipulation: The String Class
String manipulation forms the basis of many algorithms and utilities such as text analysis, input validation, and file conversion. This tutorial explores some of the needed basics. Unless otherwise noted, the following classes are contained in the java.lang library.


Primitive Types
Primitive types are the most basic data types available within the Java language; these include boolean, byte, char, short, int, long, float and double. These types serve as the building blocks of data manipulation in Java. Such types serve only one purpose — containing pure, simple values of a kind. Because these data types are defined into the Java type system by default, they come with a number of operations predefined. You can not define a new operation for such primitive types. In the Java type system, there are three further categories of primitives:


How to make hidden files in Java Program with Example
we will see how to hide file in Java or make hidden file in Java. As we said File API in Java doesn’t provide any method to make a file hidden in Java but still you can apply some quick tricks to hide files from Java program. Like in Unix environment any file whose names begin with dot (.) is hidden so you can name your file starting with dot (.) and your File will be hidden in Linux or Unix Environment.


File Handling in Java
A look at the file handling methods that Java provides, and an introduction to the complex I/O system that comes packaged in java.io. Read This Useful Java Tutorial


Class Libraries
To aid programmer productivity, the Java Standard Edition (JSE) includes several predefined class packages (aka Java class libraries). Packages/libraries discussed in this set of tutorials are: applets java.applet, language extensions java.lang, utilities java.util, precision math java.math, formatters java.text, file streams java.io, GUIs java.awt and javax.swing, network services java.net, new io (ie. memory mapped) java.nio and remote method invocation java.rmi. Other libraries include beans java.beans, communication ports java.comm, database management java.sql and security java.security. The import reserved word is used to access classes from the libraries (except for java.lang). Unless another library is indicated the following classes are contained in the java.lang package.


How to read and write in text file
Reading and writing from file in Java is very simple once you are familiar with readers, streams, input stream and output stream in Java. code example and explanation of how to read from file in java.


How to check permissions on File and Directory
In this article we will learn how to check whether file is read only , whether file has write permission or not etc. In Java we know we have file object to deal with Files if we have created any file in our application using the file object , we have the privilege to check the access permission of that file using simple method of File class in Java.


Creating Java Servlets With NetBeans
Learn to create Java servlets in the NetBeans IDE. The tutorial creates a basic mailing list and explores file access along with some DOM XML. Also covered is deploying the servlets with Glassfish.


MySQL and Java DB
So, finally, more on Java DB-- It’s the Sun-supported version of Apache Derby with all development done with the Apache Derby community. It’s a complete relational database engine, written in 100% Java with a small footprint of 2MB of a JAR file. It runs on Java EE, and Java SE and more. It has a multi-tiered design for different use cases.


Introduction – java.lang package
A package is a collection of predefined classes and interfaces, generally, having some common functionality (purpose). A package of Java is equivalent to a header file of C/C++. All the packages put together, that comes with JDK software, are known as Java API. The most important package of Java API is java.lang because without it no Java program with some functionality cannot be developed; it may be an application or applet. As this package is inevitable for each and every Java program you write, the package is implicitly imported if the programmer does not import himself; this automatic importing facility exist only for java.lang package and not for other packages.


Java beginners course
1: Basic Java
2: Procedural Java
3: Introduction to Objects
4: More Objects
5: Introducing Applets
6: Components
7: Events
8: LayoutManagers, Windows, and Dialogs
9: Images and Menus
10: I/O and Streams
11: Threads
12: Network Programming
13: Cut and Paste, Printing, Future Directions


How to use Memory Mapped File
Memory Mapped File in Java are special files which allows java program to read and write directly to memory which is extremely fast compare to stream based IO and allows programmer to code high performance java application.


Building XML With Java And DOM
This tutorial covers building basic XML structures in Java. Learn basic XML structure, and how to build XML in Java with DOM. Also learn to use the TransformerFactory to convert the DOM to strings.


How to Set Path for Java in Windows
In this Java PATH tutorial we will see what is PATH for Java, How to Set Path for Java and how to troubleshoot PATH related issues.
PATH is one of fundamental Environment variable on shell or DOS but it’s commonly associated with Java mainly because if we try to run a java program which doesn't include Java executable in PATH then we say PATH is not set for Java and we need to set path for Java. I have also seen developer getting confused over path and classpath in java.


Flexible Persistence for Java EE Applications
It is intended as a fast introduction to Hibernate and JPA for people that are already familiar with Java programming. For learning basic Java, please see these tutorials. The Hibernate and JPA training course on which this tutorial is based is usually taught on-site at customer locations, but various Java EE training courses at public venues are periodically scheduled for people with too few developers for an onsite course.


AWT vs Swing
When developing a Java program it is important to select the appropriate Java Graphical User Interface (GUI) components. There are two basic sets of components that you will most likely build your Java programs with. These two groups of components are called the Abstract Window Toolkit (AWT) and Swing. Both of these groups of components are part of the Java Foundation Classes (JFC).


How to change File Permissions
Setting file permission in Java is made convenient by methods provided in Java File class like canRead, CanWrite allows you to set read and write permission on file. you can also change permission by using same code.


How To Create A Java Executable Jar File
This is a tutorial that should help you learn how to make a jar file quickly and easily for all of your programs. Creating a jar file is not difficult to do, and it is something that should certainly be learned by beginning Java programmers.