logo

How to work with files in Java tutorial

How to open a stream, save data to a file and read data from a file in Java.

video Java Streams 101, how to read text file (00:04:48)
Java Streams tutorial, how to read text file using BufferedReader and FileReader in Java
video How to properly structure a method for accessing a file (pre Java 7 style) (00:04:27)
How to properly structure a method for accessing a file (pre Java 7 style) using try-catch-finally block.
video How to work with streams properly since Java 7 (00:02:14)
How to work with streams properly since Java 7 using try-with-resources block.
video How to read text file in Java with user-defined charset (00:02:32)
How to read text file in Java with charset (encoding) UTF-8 using InputStreamReader.
video How to easily read data from properties file in Java (00:02:37)
How to easily read data from .properties file in Java.
video How to create a properties file in Java (00:02:08)
How to create a properties file in Java.
video How to read file from JAR file (classpath) (00:02:33)
But how to read a file from classpath? Open it with getResourceAsStream method and if you want to read text file, use InputStreamReader for conversion to Reader.
video How to read and write text files since Java SE 7 (00:03:33)
How to use Java SE 7 java.nio package with classes like Files, Paths and Path to read and write text files in Java. Plus how to use UTF-8 and other charset (encoding) and how to append (not overwrite) text file.
video How to copy, move and delete file in Java since Java SE 7 (00:02:03)
Now I will show you how to use java.nio package to check if some file exists, how to copy, move and delete a file.
video How to get free, available and total disk space in Java? (00:00:56)
Since Java SE 7 you can use FileStore to retrieve these information.

Tags

rss

Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects:
github

Search