Комментарии:
Subscribed! <3
ОтветитьAs a tip in general it's a bad idea to add strings in a loop like this. But since here we know how big this file is and we know the file won't be expanded in the future it's no bid deal.
If this file was for instance inventory for a company or any file you'd expect to grow over time you should use the StringBuilder class for the string instead. The difference is StringBuilder will only use one string for the entire file whereas here we would write each line in the file as its own string.
the code differs like this:
StringBuilder s = new StringBuilder();
while (line!=null){
s.append(line+"\n");
line = reader.readLine();
}
thank you thank you thank you out of all the text read programs I wrote and tutorial for that sort of program yours is the only one that worked :D
Ответитьthere is no error coming during coding but program is not running, gives error at the time of running
Ответитьplease solve a problem
Ответитьhad alot of problems with those filereaders. first time I understand everything. great tutorial! thanks!
Ответитьsorry i don't understand when you using " text += line;" can anyone explain this to me?
Ответитьthanks for the vids I was so stuck on this.
ОтветитьHow do i read a 2d array from a text file?
ОтветитьLiked for the help then disliked for League
ОтветитьTwo questions:
1) How can I print 2 lines; so if I have hello in the first line and world in the second line how can I make it "Hello
World"
2) How can I make the path the path where the jar is located, because I need to be distributing the program so the path will change for all users.
very helpful and very well spoken. great job look forward to watching your videos in the future!
ОтветитьWhat happens with "throws Exception"?
Ответитьgreat, can you please make a video where we can match if the two files have common data in them?
thanks for the great vedio
Very clear! Thanks a lot.
ОтветитьFor the Lazy people:
FileReader file = new FileReader("C:/Users/ibrahim/Documents/NetBeansProjects/Test4_1/submit.txt");
BufferedReader reader = new BufferedReader(file);
String text = "";
String line = reader.readLine();
while (line != null) {
text += line;
line = reader.readLine();
}
System.out.println(text);
hey i want to know how can i search for a key word, such as a barcode
for instance my textfile has the code "12345678" but their will be mutliple barcodes withing this file along with a product discription and price
You actually explained this better than my uni lecturer.
You kept it concise, didn't stumble with your words and broke everything down simply without overloading it with technical bollocks.
Props to you sir.
How to save and open a file in your system? Thank you.
ОтветитьWow someone who finally can do a simple example after hours of searching. You sir, earned a subscriber.
Ответитьhow to read the file if we have more than one line..??
please help me.
can you use filereader to input string text files like scanner?
ОтветитьDo you know how to do
if I want to read string by string like function fsacnf in C
thank u (I'm beginner java)
thank you that was very helpfull!
Ответитьhow come you don't have to close the file at the end?
Ответитьcan you read multiple text files?
Ответитьdo you know how to ask user to input something and then write it into the file ???
ОтветитьIf you run into a problem searching for the file with eclipse you might wanna call it readme.txt.txt. Atleast that worked for me.
ОтветитьThank you very much Brandon and I really proud of you.
I sent you a friendship request on Facebook, hope you will accept it.
Regards
is Readline method read only a line, and is that why we had to loop readLine method, if so how does readLine method know it has to go to next line in the file for rest of the text ?
ОтветитьThank so much!! Complete Java newbie over here. Glad I found this bc I had no idea how to get started :)
ОтветитьOne question, how can we get to a new line if the text is in another line in the FILE?
ОтветитьThank you for the upload I was successfully able to read and open a file of mine. I had one question. When I put my txt file in the same package of my program it does not read it. Only way I can access it is if I specify path. Is there something i need to do to allow my program to pick up the file (read it) from within my package?
Ответитьim doing a coputer project on banking n i thought using file would be most useful as i would be able to input information n take out info n alter it according to he user's wishas in deposit /withdraw cash,bt im only in 10th grade so im gonna have to learn how to use file .i think im making gr8 progress with ur vids!!
Ответитьgreat video
ОтветитьStill can't believe java requires this many lines of code to do something so common, but it does
ОтветитьThe While loop has an error that makes the BufferedReader actually iterate through each line 2 times before doing anything with the String values. By calling "BufferedReader.readLine() != null" you are effectively skipping 1 line before the important processes are finished.
ОтветитьSuperb
ОтветитьWhat if my text file content 3rows and 3colmns and I want to read only the 2nd column ?
1 4 6
2 9 5
7 8 2
I want to read only ( 4 9 8)
Then how could I proceed?
thank you it helps my homework
Ответитьhow can i use delay function to read the text file letter by letter
ОтветитьDoes anybody have problems with reader. The problem coming in the console is: Exception in thread "main" java.lang.Error: Unresolved compilation problems:
reader cannot be resolved
reader cannot be resolved
at fileNames.main(fileNames.java:10)
how to display data in another window like in jframe?
ОтветитьSystem.out.println(text);
reader.close();
maybe you should that
How do I want the program to write on the next line of the text file?
Ответитьthanks a lot for the video. it was really helpful!!
Ответитьany way to format the text so it spaces to a new line instead of run on sentence?
ОтветитьHi Brandon. Somehow I get the following error: "Could not find or load main class ReadingTextFromFiles". I'm doing exactly the same as you in the vid. Any suggestions how to fix this and why I get this error?
ОтветитьSir, may you please do a tutorial on how to read from file recursively in java?
ОтветитьThank you for zooming in!!!!!
Ответить