Read From A File in Java - Way Easier Than You Think - #Shorts

preview_player
Показать описание
Java File IO (Input/Output) is way easier than you think it is. Reading from a file in Java can be done with just a few lines of code.

File IO is something that's daunting for a new Java learner, but you'll learn how to do file input in Java in less than a minute in this beginner-friendly Java video lesson.

Learn or improve your Java by watching it being coded live!

Hey, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java developers.

Let me know what else you'd like to see!

Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.

📕 THE best book to learn Java, Effective Java by Joshua Bloch

📕 One of my favorite programming books, Clean Code by Robert Martin

🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial

🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)

📹Phone I use for recording:

🎙️Microphone I use (classy, I know):

Donate with PayPal (Thank you so much!)

☕Complete Java course:

#Shorts
Рекомендации по теме
Комментарии
Автор

The simplest way to read a text file in Java!

Buffered reader reader equals new reader buffered reader read new file reader reader dot reader file reader dot txt reader

Yup, that's definitely Java!

ByronicGuitarist
Автор

You should close the reader in a finally block or use a try with recourses. This way it won't leak the file handle once an io exception occurs.

redcrafterlppa
Автор

Literally just what I was looking for! Thanks John.

Molotom
Автор

Your shorts are so good?!?! Never thoughts shorts code would work so well!!!

SantiagoGomez-kxqx
Автор

😀I am an old C (and ++ and #) programmer and used the File class. It is similar in Java but I also now see Path (and Paths and Files) and other related classes. I am tending to using Path more often but could sure use some guidance in that. Thanks in advance.

daveheffler
Автор

Wow, this one super simple. Loved it 😍

mahanth_ibm
Автор

Is there a benefit in using the buffered reader class over the scanner class for reading a file

aerhansrirangan
Автор

bro you are very good at teaching thanks man

jooiey
Автор

Isn’t it easier if you use Files.readAllLines?

orangeguy
Автор

Should the close be inside finally? Will the file get closed if there was some exception while reading?

aprasath
Автор

Don't forget to use finally if you don't use autoclose

brennanc
Автор

I use the out of the box nio API.
Files.readString
Files.writeString
That should be good enough for beginners to start editing and saving small files like JSONs.

wesosdequeso
Автор

What about the new NIO API in Java 8 and above John?

VuLinhAssassin
Автор

Simple way to use IO Apache application

Sybfkhevskiha
Автор

What if I want to read file at line no 10

SaszThe
Автор

Why don't you show it with try-with-resources?

macstievie
Автор

What about reading from a specific line, like if I wanted to read line 25? Would I have to iterate through the file to get the line I want to read, or is there a function where I can just enter the line I want to read as an argument?

rayNotGlorious
Автор

Do anyone know the easiest and shortest way to read an excel file? Apache Poi is a pain to me

hano
Автор

I thought for a second this video will be about how verbose Java can be, you had I am not going to lie 🤥.

ayyubayyyub
Автор

And this is why I prefer c++ sometimes

Fly_Nimbus