Java I/O Tutorial

Java I/O Tutorials

Java comes with many handy I/O classes to support the input and output through bytes stream and file system. Here’s a list of the Java I/O examples including file, temporary file and directory manipulation, encoding, serialized and also compression with zip or Gzip.

Happy learning Java I/O 🙂

File

List of the File examples to show the use of Java I/O to create, read, write, modify file and get the file’s information.

File Serialization

Take any object that implements the Serialization interface, convert it into bytes and store it into file; The file can be fully restore back to the original object later.

File Compression

File compression examples, ZIP and GZip.

Temporary File

List of the temporary file manipulation examples.

Directory

List of the directory manipulation examples.

Console IO

List of the Console IO examples.

Java I/O Reference

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
65 Comment threads
28 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
80 Comment authors
LaplasDasagriva ManuArvind yadavSTEEL ITBOYThanh Tuong Recent comment authors
newest oldest most voted
Sudar
Guest
Sudar

Hi Yong,

http://www.mkyong.com is my favourite site and I strictly followed and learned Spring AOP 2.5. As per my current project I need to convert single threaded application to multithreading. can you please add some notes/recommendations for that. I’m a beginner for threading and never implemented in my whole career

Thanks
Sudar

Bright
Guest
Bright

Hi,
As a novice of Java, the articles in your website are useful to me. Can I translate and publish them in my network?

Thinks.
Yours.

Deborah
Guest
Deborah

Hi. i have interest in java. but i have no knowledge about it. can u pls put me through.Thanks

Tanveer
Guest
Tanveer

This site is awesome for learning java.. Great Man !!

vrushabh
Guest
vrushabh

Respected sir,
I have searched very much but i did not come to know yet that how to read a audio file in java.

thanking you,

trackback
Java File I/O « Daniel Moore
sridhar
Guest
sridhar

hi i need to different between spring and hibernt

Abirami
Guest
Abirami

Hi, I want the code which meets the following requirement.
If I give the username as password, it should able to give write (access) permission to the folders in my D: drive to that user.
Could you please help me as soon as possible.
Thank you in advance.

Sarang
Guest
Sarang

these are very valuable examples…easy to follow
thanks sir

Rajesh
Guest
Rajesh

Hi… i’m just a beginner of java. i don’t know how to start it from your website. (Heard that, mkyong is a best website for learning programming skills)

hamzeh
Guest
hamzeh

hello Mr.
i want to do how can get the file size that stored in internet Before download
pleas email it for me.

Manas Sinha
Guest
Manas Sinha

Hi,

Really a good site.Just want, your answers or post should be more elaborative.

Thnks

Varaprasad
Guest
Varaprasad

Can I get more examples in regular expressions with I/O operations

harsh
Guest
harsh

hi

i have to encoded chines charactor but its can not decode its. any idea

Sujay Mandal
Guest
Sujay Mandal

This is a very helpful site .. Thank You to help us.

George Fernandas
Guest
George Fernandas

Ya This is very useful to Develope in my “PROJECT”

THANKS TO:MKYONG

Regards:
V.G.Fernandas.BE
(SOftware Engg)

SIVA
Guest
SIVA

ThanQ sir,it is very helpful to me and
can you please provide me the ORACLE & FORMS understandable website…..

kazim
Guest
kazim

Awesome .. i have become fan of u … yong

Pashalis
Guest
Pashalis

So hello i have one question about nexttoken look

String test = st.nextToken();
String test2 = st.nextToken();

if test2 is empty how can i check if test 2 is empty and put it something like test2 = “.”;

Please help me…..

sunil
Guest
sunil

Very impressive java tutorial.

Thanks

Rt
Guest
Rt

How to print output in different color on console using java program ?

Gopi Shiva Krishna
Guest
Gopi Shiva Krishna

This is an amazing site. lot of examples.

Can you also post some collection related examples.

Thanks,
Gopi.

prasad
Guest
prasad

Sir,i want the code for these questions.I tried in many ways and didn’t get the accurate result.Please do the needful. 1)Your input will given in a text file (input.txt). Your program should create an output file (output.txt). Every line in the file represents a test case for which you should have a corresponding line as result in the output file. Every line will be a mathematical expression that will be given with braces. The operators that will be used are only +,*,/,- (bodmas priority). The braces that will be used are [],() (in that order of priority). The program should… Read more »

venkat
Guest
venkat

Hi

For every thing we have an example but not much explanation.

Rimi
Guest
Rimi

How to prevent file path manipulation as it is security issue

xavy aly
Guest
xavy aly

Hi! Yong Thanks to illustrate this examples. I have one question Q:I need to create a log file which contains all the details of query done by user1 in database1 operation in oracle editor even give time and date of each query details.And when i login to another db2 and capable to fetch that log file and fired them and it could easily be capable to stored each record as it was happening in db1. note:columns name of each table is same either db1 or db2 or db3….. hope u will provide me the whole code in full explanations in… Read more »

idris adam
Guest
idris adam

the tutorial has been helpful to me, but i wanted to if it is possible to writes more than an object into a file and read them back successfully.
thank you.

stringpool
Guest
stringpool

good java tutorials

Walter
Guest
Walter

am new in programming and i want to learn and understand more programming please help me

ravi dubey
Guest
ravi dubey

The best tutorial i have ever seen:)
just awesome!!!