Java File class 📁
ฝัง
- เผยแพร่เมื่อ 5 ต.ค. 2024
- Java File class tutorial example
#Java #File #class #tutorial #example
import java.io.File;
public class Main {
public static void main(String[] args) {
// file = An abstract representation of file and directory pathnames
File file = new File("secret_message.txt");
if(file.exists()) {
System.out.println("That file exists! :O!");
System.out.println(file.getPath());
System.out.println(file.getAbsolutePath());
System.out.println(file.isFile());
file.delete();
}
else {
System.out.println("That file doesn't exist :(");
}
}
}
Hey bro, I just got a 97% on my final in my Java class and I wanted to say THANK YOU for helping to make that happen.
good work!
did you copy from google ?? xD
Congratulations! Onward you go!👏
My physics teacher was famous for saying, "Everything technical is not difficult, and everything difficult is not technical." I chewed on that for years. I think what he meant was to look for easy ways to solve problems when it's the right thing to do. Files are just files. A short video tuutorial is enough. Make it easy on yourself, because non-technical challenges await. Take care
We love seeing a file in his desktop saying nuclear launch codes 😂
bro 😂
💀
This playlist was really helpful. You made it easy for us without consuming a huge amount of time.
If I use the relative filename , the java can't find that txt file .
There are 3 solutions
1) type "src\\message.txt" or "src/message.txt" .
2) Change the eclipse working directory to the absolute pathname of the folder (src) that contains your packages and txt file .
By doing that , you can click section in top bar [Run] -> [Run Configurations] -> [Arguments] -> [Working directory] -> change from [Default] radio button to [Other] , enter your absolute pathname after [Other] -> [Apply] -> [Run]
3) type the absolute pathname .
How do i find my absolute pathname??
@@flick4556 right-click the txt.file in eclipse -> [properties] -> location
NOTE: if file.exists() always returns false, make sure to inclute /src before the name. For some reason java thinks that main.java is in the project folder when its actually in /src.
That just helps me
isn't it src/ and not /src?
@@WorstDruidEU yeah lol i was really confused for quite a bit
System.out.println("YOU ARE THE MAN, MAN!");
thank you so much
What a useful programming video, and by a person who actually talks english!
Amazing.
import java.io.File;
public class Main {
public static void main(String[] args) {
// file = An abstract representation of file and directory pathnames
File file = new File("secret_message.txt");
if(file.exists()) {
System.out.println("That file exists! :O!");
System.out.println(file.getPath());
System.out.println(file.getAbsolutePath());
System.out.println(file.isFile());
file.delete();
}
else {
System.out.println("That file doesn't exist :(");
}
}
}
This helped more than you could understand, thank you!
Thank you sir you are the most amazing teacher I've ever seen 👍
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
Nuclear launch codes 🤣 I had a good laugh now.
"Please excuse the mess".
Me:**starts breathing heavily knowing I have over 50+ files on my desktop**
So, as some people have already pointed out.
Sometimes you need to enter the complete path for the file.
You can see what that path is by right-clicking the file in the project tree and choose "Properties".
Then copy all of that and use it instead of just the file name.
That just helped me now😭😭. Thank you unknown helper 💗💗
Keep your text file outside your src folder incase if file.exists() always returns false...
Thanks.
WE back at it again, epic vid homie
let's gooooooooo
Thank you for this very useful video!
Hey, Thank you for the awsome learning experience... You've been a great help through my Java class this term. :)
اقسم بالله عظمة !!
Awesome video, I love the way you explain new concepts
Waiting for DataStructure in java full Video , Please keep going, and thank You.
good one, nice video.
Cool! Easy to follow
Love your videos! Everything becomes so easy
Here's a prayer to the youtube algorithm. :D Thank you Bro Code for amazing videos!
I find these videos so helpful. One problem I have with files though is when I make an installer for an application which allows a user to define where they want to install to, how can I set that file path then back in the application so it reads and writes to that file?
Thank you Bro code !!! Appreciate your work man ... Keep up the good work .
He is a legend,gamer+programmer
Best TH-cam teacher ever
Thank you for all your work on these videos
Hey i got a problem with my Intelidea that the program doesn't recognize the file for an unknown reason, showing on console that file doesn't exist...
Only when i put full path, than all works fine..
yes it happens for me too! i'm using linux so maybe it has something to do with that..... idk
love your technique
bro
I am loving with bro code for his coding content.
thanks very nice vid & explanation
Thanks, Bro! ☕ You're awesome!
Thanks Bro for this awesome videos, stop making Java easy to understand
Thanks! Cramming and my prof didn't cover this topic :/
I don't quite understand the file.delete part. Shouldn't the program every time you start it create a file (File file = new File("poem.txt");) , so eventually only the first condition of if statement (file.exists()) would be fulfilled. I know the file gets deleted by the end, but with another start of the program it is created again. So like, why every other start of the program ignores the File file = new File(); line.
beautiful work my lord
thank for this
Dude you are amazing!
nice
super helpful, thanks bro
thakyou so much for the videos
Hello,
I am developing android java filemanager app.. I used checkbox to check 1/file.mp4
2/folder(files+sub folders)
.
How can i add copy paste feature for checked 1, 2 file folder fully at same time ?like -google filemanager app..
Advance Thanks
Short N Sweet
sheiii bro
love the easter eggs
💪
super
Thanks a lot!
You are just awesome 😎
Thank you very much
Hello , i have a question please , i did all the instructions but it shows no file for some reason , why is that ?
Edit: its ok comments already answered that , keep the great work man
thanks! really well explained!
Thank you so much sir.
Amazing bro!
Bro I learn a lot from you thank you
Just the best
thanks
Simply superb👍
thanks for watching Lakkoju!
keep the good work up brother
Great!
you are realy helpful bro. :)
Thanks bro.
nice video
thank you bro
nice video buddy...
who can resist this thumbnail
Good video!!
best brooo
I do have a file but it won’t full the array
Thanks
thank you, you are the best : >
Thanks, Bro!
Don't we have to close the file afterwards?
thanks bro
best bro ever!
i'm hungry
still hungry?
Bro i just want u to know; you re saving my ass ! thank u soo much !!!
I love you bro
Goat
😇❤
can i have the Nuclear launch codes pls AHAHAHA
Thank you bro, comment for the bro code
EPIC
dude you live in my heart S2
nice 2.0
4:38
hey bro can you paste the code in the comment
nuclear launch codes... 💀💀💀💀💀💀
come on bro we want spring framework and spring boot
"NUCLEAR LAUNCH CODES" XDDDDDDDDDDDD
i wanna know what the fuck exactly resides in that XDDDDDDDDDDDDDDD
import java.io.File;
public class Main
{
public static void main(String[] args){
File file = new File("song_lyrics.txt");
if(file.exists()){
System.out.println("That file exists! :O!");
System.out.println(file.getPath());
System.out.println(file.getAbsolutePath());
System.out.println(file.isFile());
file.delete();
}
else{
System.out.println("File does not exist");
}
}
}
Watch now
I click your ads bro !!
Add a public comment...
Yo just wanna say that GOD loved the world so much he sent his only begotten
son Jesus to die a brutal death for us so that we can have eternal life
and we can all accept this amazing gift this by simply believing in him (Jesus) asking for the forgiveness of your sins
and forming a relationship with heavenly father.
A comment