Video is ready, Click Here to View ×


File I/O is an inescapable part of being a software developer.

In looking at the Javadoc for the java.io package, we see a dizzying array of classes.

Do you use byte streams or character streams? Which classes do you use?

In this episode I’ll break it down and help you make sense out of it.

As Java developers, we need to read and write files all the time.

The JDK’s io package provides us with a lot of great tools for doing so, but can be daunting for new developers.

The text file is by far the most common type of file I use in the business world, so that’s what I’ll focus on in this video.

I’ll show you how to read and write text files using the Reader and Writer, respectively.

There are lots of classes, but I like those and recommend them for processing text files.

In this video, I’ll show you how to:

* Create test data using lorem ipsum (7:45)
* Use FileReader to read from a file (12:00)
* Use FileWriter to write to a file (13:10)
* Use InputStreamReader to read a file (17:55)
* Use OutputStreamWriter to write a file (19:52)

Java I/O Javadoc: https://docs.oracle.com/javase/8/docs/api/java/io/package-summary.html

Javadoc: AutoCloseable interfce: https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html

Lorem Ipsum generator site: http://generator.lorem-ipsum.info

Github URL: https://github.com/makotogo/IO101

Subscribe to Makoto TV if you liked this video: https://www.youtube.com/channel/UCAoqQ5DnRyLisPdzUodMrww

Check out our blog: http://makotoconsulting.com/blog

Follow me on Linked In: https://www.linkedin.com/in/jstevenperry1
Follow me on Twitter: @jstevenperry

Thanks for watching!