Java File I/O (Reading & Writing)

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Instagram: / keep_on_coding
    Twitch: / keeponcoding
    Discord: / discord
    My Gear: amazon.com/sho...
    #keeponcoding #tech #programming

Комментарии • 128

  • @KeepOnCoding
    @KeepOnCoding  Год назад +1

    ☕Want to master Java? Get my complete Java course: bit.ly/42mQlXE

  • @ianpan0102
    @ianpan0102 4 года назад +44

    I was planning on refreshing my memory on Java and found your playlist -- best thing I've come across this week!

  • @mycodegist4258
    @mycodegist4258 4 года назад +62

    Your video quality is top notch.
    The sound is crispy clear too
    Keep up the good work, this video was helpful!
    Cheers!

  • @christler801
    @christler801 4 года назад +26

    Good stuff! I am learning Java now and just got through the File I/O section.
    Last week I was learning exception handling when your video on that came up.
    Keep it up

  • @DmytriiPavlichenko
    @DmytriiPavlichenko 3 года назад +2

    Streams closing in "try" section? So bad practice... Be cleaver, do it in "final" block

  • @itheblackwolfofmyfamily
    @itheblackwolfofmyfamily 4 года назад +7

    We can also have try with resources because the bufferewriter will be closed automatically. This is good because we may forget to close the bufferwriter.

  • @haphazardhaywire
    @haphazardhaywire 2 года назад +1

    Which application have you used for programming in this video?

  • @ErionMaxhari
    @ErionMaxhari 4 года назад +7

    I am learning Java since a year now, and this is the best channel across youtube.

  • @leanobajio
    @leanobajio 4 года назад +5

    Hey! Awesome video! Could you do a video about your environment setup for coding in java. What IDE do you use/prefer? Maven or Gradle? etc.

  • @sews5742
    @sews5742 3 года назад +5

    good quality video, thank you.
    the only things i would've liked added are how to use bufferedwriter without overwriting the current state of the text file, and how to create a text file just inside the project folder in case it needs to be moved between pcs
    both of which probably have easy to find solutions online though, so it isnt an issue
    edit:
    to anyone with the same questions, you can append instead of overwriting by adding true as a parameter in FileWriter: FileWriter("path", true)
    and you can write to a file inside the project folder by just typing the file name without a path, like FileWriter("textfile.txt")

    • @ezequielschmit
      @ezequielschmit 3 года назад

      Thanks a lot man, it was very helpful

    • @sews5742
      @sews5742 3 года назад +1

      @@ezequielschmit glad it helped

  • @draculaoppa834
    @draculaoppa834 4 года назад +19

    Never put blank or return; in catch block when you use try-catch. You can't know where the error has occured when the project is too large. That's the bad practice!

    • @giangnguyenbang8073
      @giangnguyenbang8073 3 года назад +1

      he is demo :3 calm :3

    • @thatoneuser8600
      @thatoneuser8600 3 года назад +5

      @@giangnguyenbang8073 If you're teaching to newbies-such as in this video-, then that is a profoundly horrible excuse.

    • @DueSouthWests
      @DueSouthWests 2 года назад

      So is someone gonna give an example for what a beginner should wright? Like I would really like to know as a beginner.

    • @draculaoppa834
      @draculaoppa834 2 года назад

      @@DueSouthWests What I said (Knowing the consequences!) is what all beginners should know about!!! Just listen to understand but not to reply.

  • @westonpeabody8010
    @westonpeabody8010 3 года назад +3

    Just wondering how you learned Java. I've been kinda self learning for a while. Took a break and I'm kinda having a hard time wrapping my head around some things

  • @Dav95id
    @Dav95id 2 года назад +2

    Bro! I thought i was gonna freak out because of my university excercises, but now I am laughing because you showed me how frickin' easy this is :D Thank you so much!

  • @TheAndroiD619
    @TheAndroiD619 4 года назад +3

    Can you please discuss how to find jobs as a Java developer (assuming 0 experience)?

    • @pooblock4092
      @pooblock4092 3 года назад

      intern jobs or junior dev jobs for the government are easy to get. Depending on where you live the government is looking for lots of people as developers. It's a great place to start.

  • @AnirudhSharma9211
    @AnirudhSharma9211 3 года назад +2

    Karen, Chad and Becky LMAO

  • @greynade
    @greynade 4 года назад +2

    Expecting you to reach 100k soon!
    Please keep making such short and specific videos.
    Maybe a video on CUSTOM THEMES ? like "Custom Dark Theme" , "Default Night Mode" , Custom Brand Color Theme" , etc!
    Would love a such video

  • @rorronoazoro5537
    @rorronoazoro5537 3 года назад +1

    Thank you sir! If I want for example couple of users to enter their Names how not to override the first name with the second name, etc etc?

  • @vighnesh93
    @vighnesh93 3 года назад +3

    Really really helpful. Loved the clarity and simplicity of your content. Please keep posting 🙌🏼

  • @guyteigh3375
    @guyteigh3375 9 месяцев назад

    Helpful thank you. Is there a (simple) way to ADD to a file (eg a logfile) using this approach, rather than have it just overwrite each time. I realise there are other ways it can be done, but this seemed simpler than most of the ways I have foiund so far - hence wondering if there was an option / switch / parameter to say "dont overwrite, just append this on to it".
    Many thanks.

  • @salmali9039
    @salmali9039 Год назад

    Do you can solve this:
    Build Application that has three classes (three user data types). Every class has
    some of attributes and methods to manipulate the objects of these classes.
    The objects and their data can be saved permanently into Files. Every class have
    to save in three forms of files:
    1. Object Stream.
    2. Data Stream.
    3. Random Access File Stream.
    Data can be brought mainly from csv file. Every record consists of multiple fields,
    and every line has only one record.

  • @Motivational-Mango
    @Motivational-Mango 6 месяцев назад

    very good. i like txt file. i write many thing like about the world and about dogs and cats in the file. i write very good information in the file.

  • @UyenNguyen-m1m
    @UyenNguyen-m1m 10 месяцев назад

    Hi, may u answer my question, I am just curious about the try catch parts, what do it gonna do? also why do we have to handle that exception as well as what will happen if we just dont handle the exception?

  • @ahmadfx8962
    @ahmadfx8962 2 года назад

    if finished the app and then i want to give it to client, how to make path to my client directory ? maven give me this>>Required filename-based automodules detected. Please don't publish this project to a public artifact repository!

  • @sollee245
    @sollee245 3 года назад +1

    how easy this video is!!! Thankyou for sweet explanation XD

  • @DrSaav-my5ym
    @DrSaav-my5ym 2 года назад

    I typed exactly what you typed here and I got an error "fileName cannot be resolved to a variable"

  • @monstergamers653
    @monstergamers653 2 года назад

    how do I send it to a folder that no one else will likely have? I tried making a folder in my C: drive to send it to but no one else will likely have that folder.

  • @Allen-pj7nw
    @Allen-pj7nw 10 месяцев назад +1

    Your setup is cool

  • @An-fu9ui
    @An-fu9ui Год назад

    Sir, i want to ask you how to create an object like for example Class Student in file io ?

  • @lazarvukosavljevic2730
    @lazarvukosavljevic2730 2 года назад

    Bro this video is helpfull only if you have like 3 yrs of exp behind you, not beginner frendly

  • @marissawebb7671
    @marissawebb7671 3 года назад +1

    I'm taking Java now and I'm so thankful for this video!

  • @nishantjasra5291
    @nishantjasra5291 2 года назад

    It Created the file and wrote too, but unable to read the code in IDE by second code

  • @JLSXMK8
    @JLSXMK8 3 года назад +1

    I love how you added in a way to copy files instead of just doing a "hey, we're gonna write to a file."; That technique can be VERY handy in case of accidental deletion of a file.

  • @djebelqaf5217
    @djebelqaf5217 3 года назад +1

    Thanks for the video, i sleep early tonight

  • @amalalmuarik5160
    @amalalmuarik5160 2 года назад

    i don't get why do we need to open a file and write on it are we writing on outer file not ours or my own file
    ?

  • @AmandeepPatro
    @AmandeepPatro 5 месяцев назад +1

    just wow

  • @christophernoble8284
    @christophernoble8284 3 года назад +1

    This is a great video. Voice tone, editing, it's perfect man thank you.

  • @hanzspecter203
    @hanzspecter203 2 года назад

    I was wandering how do I create a file where the USER can write in it?

  • @jaylordjl6337
    @jaylordjl6337 2 года назад

    Thankyou sir please post more file Handling

  • @shiroisekai_20
    @shiroisekai_20 2 года назад

    is it possible to use this method to make a user password program

  • @quantum_psi
    @quantum_psi 2 года назад

    "Beginner". This shit was too hard to follow

  • @ahmedababneh7089
    @ahmedababneh7089 4 года назад +5

    All the dislikes are from Karen

  • @harshalkotkar4531
    @harshalkotkar4531 9 месяцев назад

    Just amazing in easiest way, thank you 👍

  • @maddy3656
    @maddy3656 4 года назад +1

    Great video. Thank you! 🙌🏾

  • @msnraju97
    @msnraju97 2 года назад

    what str. in bw.write line? even without it will work?

  • @zozowrites4467
    @zozowrites4467 10 месяцев назад

    Thanks, was really helpful!😀

  • @joesmall8650
    @joesmall8650 3 года назад

    Which platform do you use?

  • @amolsushir3198
    @amolsushir3198 2 года назад

    Excellent stuff!! You solved my problem in 7 mins.
    Also can pls explain how can I limit the number of characters in a particular cell of a csv file. For example upto 2000.
    Please help.

  • @waytoallah5831
    @waytoallah5831 2 года назад

    my text is in the same line even when i write

  • @altechy7304
    @altechy7304 3 года назад

    hey man!... did you ever get the "I want to be like you" ?... LOL Congrats and thank you!

  • @yadigaryusifov1279
    @yadigaryusifov1279 3 года назад

    when I wrote backslash, it did not create a new line. Could you clarify me on this problem?

  • @danieloguhebe1669
    @danieloguhebe1669 4 года назад

    But you didn't cover how to read from excel files using java.io.*;

  • @JJJJ-gl2uf
    @JJJJ-gl2uf Год назад

    Great video. Many thanks.

  • @CashmereMercenary
    @CashmereMercenary 2 года назад

    nice, thanks for that. However i tried reading from some an excel i created earlier with various columns and rows but i just a lot of binary among other characters. i initially read and wrote to .xls instead of the .txt which worked fine. any ideas?

  • @JuanCruz-iu9ul
    @JuanCruz-iu9ul 3 года назад

    When My mentor told me we were doing FILE i/o i was kinda scared lmao but it is way easier that what I thought

  • @sebastienroux1790
    @sebastienroux1790 2 года назад

    Id love to see how you handle server side receiving post requests from a video upload.

  • @DZITSEWISDOM
    @DZITSEWISDOM 5 месяцев назад

    how can i code a bar chart in java

  • @nicolapetkovic7910
    @nicolapetkovic7910 3 года назад

    I've found this video useful because you give a solution to a common problem by easy and clear way

  • @askin_guy4652
    @askin_guy4652 2 года назад

    so buffered readers and writers are restricted to only one functionality (method)?

  • @kevser176
    @kevser176 9 месяцев назад

    that was the most useful video about file i/o on youtube for me. thanks
    maaan

  • @pooblock4092
    @pooblock4092 3 года назад

    Sick video, we were given shit content on this in college and this will help me out with the assignment lol.

  • @alisherry2932
    @alisherry2932 2 года назад

    What we should do if we need to edit some information in the saved file without losing the other data?

  • @gopixus
    @gopixus 4 года назад

    Great content but why only 1752 views? Sub!

  • @giacomomosele2221
    @giacomomosele2221 3 года назад

    I need this for an application to write its log to a file. Thank you so much!

  • @csongorcsizmadia6765
    @csongorcsizmadia6765 3 года назад

    thank you so much! They didn't really explain this at the java lecture, so your video was very helpful!

  • @alainj490
    @alainj490 2 года назад

    Very clear, now I understand. Thank you so much!

  • @miguelmora2141
    @miguelmora2141 2 года назад

    How do you print out every line in reverse alphabetical order?

  • @n9583
    @n9583 3 года назад

    Amazing video but Is it the same for Mac?

  • @shahadhussein9708
    @shahadhussein9708 3 года назад

    what if I wanted to print a specific line from a file? can anyone help?

  • @kalashacharya9821
    @kalashacharya9821 3 года назад

    The code of #2:46 gave the error.
    Instead, I have to modify the code as below to run without error.
    Can anyone explain to me why?
    import java.io.*;
    class Main {
    public static void main(String[] args) {
    try {
    BufferedWriter bw = new BufferedWriter(new FileWriter("F:\\JAVA\\InputOutput\\output.txt"));
    bw.write("karen");
    bw.write("\t chad");
    bw.write("\t becky");
    bw.close();
    }
    catch(Exception e) {
    return;
    }
    }
    }

    • @thatoneuser8600
      @thatoneuser8600 3 года назад

      Maybe you wrote the absolute path starting at the F drive rather than the C drive?

  • @mo-_-om7475
    @mo-_-om7475 3 года назад

    how to check if the words in a text file Palindromes are or not?

  • @bwb3881
    @bwb3881 3 года назад

    What is the meaning of str ?

  • @ahsaniqbal4122
    @ahsaniqbal4122 3 года назад

    My men love u, U have explained it beautifully.

  • @gothfrog69
    @gothfrog69 2 года назад

    Clear and concise example of file reader/writer. Thank you.

  • @isadorasantos2442
    @isadorasantos2442 3 года назад

    Thank you so much for this video. Helped me a lot with my assignment!

  • @sekoubasillahcamara5791
    @sekoubasillahcamara5791 2 года назад

    Damn you made this look very easy. Thanks mate

  • @ahmadasfour6715
    @ahmadasfour6715 3 года назад

    Really good as it is to the point and you were easy to understand. Thanks.

  • @ahmadhasham6890
    @ahmadhasham6890 3 года назад

    can we write and read from a text file in a single java file?

  • @shivasundar1998
    @shivasundar1998 2 года назад

    You look like Charlie Cox

  • @ryanfuller8690
    @ryanfuller8690 3 года назад

    what is it called with how his bw.write(str:) like it's showing you your method/function is a string. I notice that in all his videos that it tells you what it is.

  • @skud1377
    @skud1377 2 года назад

    worked great thanks

  • @Jeff-zc6rr
    @Jeff-zc6rr 2 года назад

    Append to the file?

  • @moaaatekita8827
    @moaaatekita8827 Год назад

    Arigato onichan

  • @lilasian3877
    @lilasian3877 3 года назад

    Great video man! Keep up the good work

  • @charlesochanda5111
    @charlesochanda5111 4 года назад +2

    Great video! great quality! great explanation! 👏 but I think most of us enjoy watching non-coding related videos more😄

  • @yadigaryusifov1279
    @yadigaryusifov1279 3 года назад

    Thanks for the great explanation.

  • @alexop5919
    @alexop5919 3 года назад

    What a mess code

  • @ibrahimazam1157
    @ibrahimazam1157 3 года назад

    I wish my assignments were as simple as this 😪

  • @sanchitlodha5770
    @sanchitlodha5770 3 года назад

    Thank you for getting me started on java io

  • @rhsliza7023
    @rhsliza7023 Год назад

    thanks sir

  • @Momo-qr3rd
    @Momo-qr3rd 2 года назад

    Thanks Bro

  • @marryammalik9500
    @marryammalik9500 3 года назад

    Thanks alot

  • @shanesreal
    @shanesreal 3 года назад

    Well done thumbs up

  • @Forrest-777
    @Forrest-777 2 года назад

    Nio > io

  • @randomstorywa5107
    @randomstorywa5107 4 года назад

    How about integer in Bufferwriter?

  • @randomstorywa5107
    @randomstorywa5107 4 года назад

    How about integer in Bufferwriter?

  • @maxd7228
    @maxd7228 4 года назад

    Need More Java content. Great how-to 👍

  • @ravikiran514
    @ravikiran514 3 года назад

    wow

  • @abukmoha5092
    @abukmoha5092 3 года назад

    thank you very help full....

  • @cityzenctm3932
    @cityzenctm3932 3 года назад

    Thanks you're awesome

  • @justhereforkpop
    @justhereforkpop 2 года назад

    ?