File IO | File handling Tutorial in java in detail

You are here : Home / Core Java Tutorials

File I/O streams in java >

File I/O in java - streams (Input/output), Readers/Writers, Buffered



Create new File in current or specified directory >

Create File using createNewFile() method in java file IO




Find current working directory or current path in java




Create File in current path using new File(currentPath, fileName), File.separator or System.getProperty("file.separator") in java file IO



Find parent Directory and available disk drives in system >

Find parent Directory in java




Find the available filesystem roots in java/ Available disk drives in windows




Execute CMD command through java program >

Execute CMD commands through java program




Read text entered by user in console>

Program to Read text entered by user in console using DataInputStream in java file IO




Read text entered by use in consoler using BufferedReader's readLine() method in java file IO



Program to Read text entered by use in console using java.util.Scanner



Program to Read text entered by user in console till some special character (let's say @) in java




Read file using FileInputStream and BufferedInputStream >


Read text from file using FileInputStream in java file IO




Read text from file using BufferedInputStream (and FileInputStream) in java file IO





Title

Write in file using FileOutputStream and BufferedOutputStream >



Write String to file using BufferedOutputStream (and FileOutputStream) in java file IO




Write String to file using BufferedWriter and FileWriter in java file IO



Program to Write in file using PrintWriter to in java




Try with resource in java 7 - Read text from file using BufferedInputStream / FileInputStream and Try with resource >


Try-with-resources in java7 - java.lang.AutoCloseable interface



Program to Read text from file using FileInputStream and Try with resource provided in java 7



Program to Read text from file in String using BufferedInputStream and Try with resource provided in java 7




Write byte Array in file and read it >

Program to Write byteArray to file using FileOutputStream in java file IO



Program to Read file in byteArray using FileInputStream in java file IO




Write in file using FileWriter and Read file using FileReader >

Program to Write to file using FileWriter in java file IO



Program to Read text from file using FileReader in java file IO




BufferedReader and FileReader >

Program to Read text from file using BufferedReader's read() and readLine() methods in java file IO



Should we close both FileInputStream and BufferedInputStream | BufferedReader and FileReader >

Should we close both FileInputStream and BufferedInputStream ? OR BufferedReader and FileReader ?



Use Mark and Reset methods of InputStream >


Program to How to use Mark and Reset methods with BufferedInputStream



Program to How to use Mark and Reset methods with BufferedReader




Encrypt and decrypt text using password - Write encrypted text to file and Read encrypted text from file in java >


Program to Encrypt and decrypt text using password - Write encrypted text to file | Read encrypted text from file in java




Important Differences in File handling  >

Difference between FileInputStream and BufferedInputStream in java file IO



Difference between Stream (FileInputStream) and Reader (FileReader) in java file handling



Difference between FileReader and BufferedReader in java file IO






Create File using createNewFile() method in java file IO


Copy a file in java 2 in ways - use org.apache.commons.io.FileUtils's copyDirectory(sourceDirectory, destDirectory)




Program to Move a file - in java file IO




Program to Rename a file - in java file IO



Program to Delete a file - in java file IO



Program to Find file exists or not - in java file IO




Program to Append to file using FileOutputStream in java file IO




Program to Hide and unHide File or Directory (by executing CMD commands in java program) till java6 - file IO




Program on How to hide and unHide file or Directory in java 7 using java.nio.file




Program to Find file is hidden or not till java 6 | And also In java 7




Program to Find creation, last modification and last accessed date of file in date, month and year in java7 using java.nio.file




Program on How to Compare two file or Directory path - in java file IO




Program to Find file size in bytes, Kilobytes, megabytes and gigabytes using length method of File in java




Program to Make a file READ ONLY in java




Program to Find file is Read only or not in java 7




Program to Make a file readable and writable in java







Directory operations - create, identify, delete, copy, traverse >


Program to Create Directory - Single and multiple (i.e. parent and child directories) in java file IO




Program to Identify File or Directory - in java file IO | And in java 7 using java.nio.file




2 Program to Delete a Directory - using File.delete and org.apache.commons.io.FileUtils's deleteDirectory(dir)- in java file IO





Program to Copy a Directory - using org.apache.commons.io.FileUtils's copyDirectory method- java file IO





Program to Traverse a Directory (all sub-directories and files) in 2 ways | using org.apache.commons.io.FileUtils in java file IO










Few more >


Program to Replace all the occurrences of searchWord in the file with replaceWord in java




Program to Replace all the occurrences of searchWord in the file with replaceWord in java using byte array





Program to Sort all contents/words of file in java





Program to Sort all contents of file by line in java




Program to Create property files and store key-value pairs in it | And how to read property file in java




Program to Convert Property file to Xml File in java




Program to insert/write content at specific position in file in java




How to Read/write from file using RandomAccessFile




Skip Characters while reading text from file in java










Difference between getPath(), getAbsolute() and getCanonical() file path methods in java | Relative and Absolute path





Difference between loading file with FileInputStream and getResourceAsStream() in java





Download image from specified URL in java





How to create password protected zip files | Zip and unzip directories | zip and unzip specific files in java | Unzip JAR file





2 ways to Count number of lines in file in java




SequenceInputStream to read data from multiple files (two or more) and writing it in one file in java




















Write data types byte, short, char, int, long, float, double and boolean in file and read them >

Program to Write BYTE data type in file using DataOutputStream and Read BYTE from file using DataInputStream - java file IO




Program to Write SHORT data type in file using DataOutputStream and Read SHORT from file using DataInputStream - java file IO




Program to Write CHAR data type in file using DataOutputStream and Read CHAR from file using DataInputStream - java file IO




Program to Write INT data type in file using DataOutputStream and Read INT from file using DataInputStream - java file IO




Program to Write LONG data type in file using DataOutputStream and Read LONG from file using DataInputStream - java file IO




Program to Write FLOAT data type in file using DataOutputStream and Read FLOAT from file using DataInputStream - java file IO




Program to Write DOUBLE data type in file using DataOutputStream and Read DOUBLE from file using DataInputStream - java file IO




Program to Write BOOLEAN data type in file using DataOutputStream and Read BOOLEAN from file using DataInputStream - java file IO








Customizing  Serialization process by implementing Serializable and Externalizable >

Avoid ObjectInputStream.readObject() from throwing EOFException at End Of File in java  




IMAGE - Storing in and retrieving out from database


JDBC- Insert/Store/save IMAGE in database by using PreparedStatement's setBinaryStream and executeUpdate methods, using BLOB data type - in java



JDBC- Retrieve IMAGE from database by using PreparedStatement's executeQuery, ResultSet's getBlob method - using BLOB data type - in java



FILE - Storing in and retrieving out from database


JDBC- Insert/Store/save FILE in database by using PreparedStatement's executeUpdate and setCharacterStream methods, using CLOB data type - in java



JDBC- Retrieve FILE from database by using PreparedStatement's executeQuery and ResultSet's getClob method, using CLOB data type - in java





No comments:

Post a Comment