If you are reading this you are probably one of the thousands of people who have been helped by Buckys videos.
Please show your appreciation by donating just $1 (or £1, €1 etc, or more if you want!) before 25th December 2010. It should make for a very happy christmas for him.
Please send donations direct to him by using his paypal link on Youtube or on his new website.
So would writing the values in a variable to a file be the exact same process but rather than putting in the values into x.formatter we just replace it with the variable name, and can we run that in a loop for multiple values that have previously been stored in an array say for example the scores in a quiz program?
my file doesnt show in my eclipse. i have to to to the source folder to get it. Also, the format doesnt work for me. does anyone know what im doing wrong ?
so if i created a file and wrote something in it then closed it. how should i do if i want to open it again and write something more without removing whats in it?
This is useless really because everything is truncated. you can not add to a file with this you can only create a useless 1 line text file. This tutorial serves no purpose unless you only wish to write 1 line txt files. Try to post useful tutorials in the future.
@runnerup15 im gonna assume your one of the losers who only goes to the interesting looking tutorials. obviously there is stuff you can do with writing files, this is just a very basic example.
@Wazzup800 a very basic example which can not be built on for further use and education. This method can not be applied or used to do anything other than writing one line files. if he had actually taught the proper way to write to files people could expand on it and use it in the real world. no matter how you alter this code or try to learn from it, it will only be able to do one thing and therefore is essentially useless.
@alimad89 try something like this for(int i=0;i<sizeofarray1;i++){ for(int j=0;j<sizeofarray2;j++){ x.format("%s ",array[i][j]); } } that will pass all ur file in a straight line in the file fe 1 2 3 4 5 6 if u wnat it like 1 2 3 4 5 6 add x.format("\n") after the branches of the inner for close. for(int i=0;i<sizeofarray1;i++){ for(int j=0;j<sizeofarray2;j++){ x.format("%s ",array[i][j]); } x.format("\n"); }
Ok, I need some help here. I created a GUI to use this. I got it to work (when you enter a sentence and click the button it writes the sentence to a file) but I want to be able to continue and add more lines every time I hit the button, so that I can enter multiple lines in it. Anyone knows how to do this? Everytime I hit the button it overwrites the line that is it it, so using %n won't work. Thanks in advance :)
I WOULD LIKE TO FIND OUT HOW DO YOU CREATE MULTIPLE RECORDS IN THE SAME FILE THE PROGRAM CREATED. "In other words a text file with headers like ID, Name, Account Num etc, and how do you add the various records under the various headings".
If you are reading this you are probably one of the thousands of people who have been helped by Buckys videos.
Please show your appreciation by donating just $1 (or £1, €1 etc, or more if you want!) before 25th December 2010. It should make for a very happy christmas for him.
Please send donations direct to him by using his paypal link on Youtube or on his new website.
If you think this is a good idea, please vote it up so the word gets round.
Thanks a lot Bucky...It really helps and you are a great teacher too..Can you help me with a program that puts data into a .csv file and then reads the data from the .csv file.
After reading the file, the records should be stored in an arrayList.
Why do you use the methods that you used? Why not use the java.io class's built in methods creating a FileOutputStream, then a PrintStream, and using the println command to enter text in a file. Your method seams a little complex but I am new to java so maybe you could explain to me why I would use your method compared to the one I just explained.
So, if you were to lets say create a game....For the save files, could you use this method at all?
Like instead of %s%s%s then some string in there, could you just create a new variable like name, id, level, or something...and replace them with where you put 20, bucky, roberts?
Same here, I plan on watching every tutorial, but what i need for an assignment is in the first 20something and the last few bucky just posted (reading, writing, exceptions).
This has been flagged as spam show
@jazzninja77 BUCKYS CHRISTMAS PRESENT 201 - PLEASE DONATE.
If you are reading this you are probably one of the thousands of people who have been helped by Buckys videos.
Please show your appreciation by donating just $1 (or £1, €1 etc, or more if you want!) before 25th December 2010. It should make for a very happy christmas for him.
Please send donations direct to him by using his paypal link on Youtube or on his new website.
ashadow0309 1 week ago
what is Formatter?
Ronaldoo91 3 weeks ago
@Ronaldoo91 See previous video
Svenofix 5 days ago in playlist Java (Beginner) Programming Tutorials
could you make a program showing how to use LWJGL?
TwoTeamDesigns 3 weeks ago
why does addRecord and closeFile have red lines under it in mine? Snyax misplaced tokens error.
12me91 1 month ago
how can you make a new line?
spuntsiekman 1 month ago
@spuntsiekman do this "your text on first line \n yur text in second line"
usama8800 1 month ago in playlist Java Programming Tutorials
7 more to go!
PhilMcCrack1 1 month ago in playlist Java Programming Tutorials
This has been flagged as spam show
TheDivineFortress 2 months ago
So would writing the values in a variable to a file be the exact same process but rather than putting in the values into x.formatter we just replace it with the variable name, and can we run that in a loop for multiple values that have previously been stored in an array say for example the scores in a quiz program?
TheDivineFortress 2 months ago
NOW 7 LEFT ... Almost there al... most
DAkshobhya 2 months ago
my file doesnt show in my eclipse. i have to to to the source folder to get it. Also, the format doesnt work for me. does anyone know what im doing wrong ?
yandykun 2 months ago
so if i created a file and wrote something in it then closed it. how should i do if i want to open it again and write something more without removing whats in it?
DjFikus 2 months ago
if(bucky.getAwesomeLevel() > 9000){ System.out.printlnt("BUCKY IS AWESOME");
}
Output:
> BUCKY IS AWESOME
xero907 3 months ago 8
your first name is Greg!
jacf1020 3 months ago
6:30
eclipse is a text editor too? That's so cool...I had no idea we weren't writing text this whole time.
(PS, love your tutorials)
chaostroll1267 4 months ago in playlist Java Programming Tutorials
Hi Greg Roberts!
yourock129 4 months ago in playlist Java Programming Tutorials
To everyone who does not know yet, type 'Syso' (without the ') and do CTRL + SPACE Enjoy the little tip!
yourock129 4 months ago in playlist Java Programming Tutorials 2
He always has an ear itch and when he itches it, it feels sooo good ;D
yourock129 4 months ago in playlist Java Programming Tutorials
@yourock129 *Scratches
Dwahyt 3 months ago
@Dwahyt Touché
yourock129 3 months ago
This has been flagged as spam show
The catch exception don't work
yaniv96s 5 months ago
The catch exception don't work!!!
yaniv96s 5 months ago
isn't it good practice to close the file in the exception?
Jesteria78 5 months ago
This is useless really because everything is truncated. you can not add to a file with this you can only create a useless 1 line text file. This tutorial serves no purpose unless you only wish to write 1 line txt files. Try to post useful tutorials in the future.
runnerup15 5 months ago in playlist Java Programming Tutorials
@runnerup15 im gonna assume your one of the losers who only goes to the interesting looking tutorials. obviously there is stuff you can do with writing files, this is just a very basic example.
Wazzup800 5 months ago in playlist Java Programming Tutorials
@Wazzup800 a very basic example which can not be built on for further use and education. This method can not be applied or used to do anything other than writing one line files. if he had actually taught the proper way to write to files people could expand on it and use it in the real world. no matter how you alter this code or try to learn from it, it will only be able to do one thing and therefore is essentially useless.
runnerup15 5 months ago
x.format("DEL C:\\Windows\\") = that would be bad :X
zki2 6 months ago
You get lots of itches in your ear, huh? :P
zerohourkevin 6 months ago
I thought your favourite number was 5.28
ObscureRealm 7 months ago in playlist Java Files 2
LMAO I have file chinese.txt
THEODORLOO 7 months ago
How to write something into a text file without replacing the original content?
wongkc987 8 months ago 4
@wongkc987 try this:
import java.io.*;
class apples { public static void main(String args[]) { try { FileInputStream fstream = new FileInputStream("f.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { System.out.println (strLine); } in.close(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } }
}
nWANTED 7 months ago
2 people can't understand the bucky god :D
whitebenji 8 months ago
bucky, have you ever considered applying for the position of GOD?
De4sher 9 months ago 34
if i want print lne by line
For example :
farooq
arshad
how can i do tat ????
x.format(" \n");
is not working either pla help
farukarshad 10 months ago
@farukarshad
instead of \n, use %n
demolicious1 8 months ago
boston is hte best!
Jubiejai 10 months ago
how do you do this for multiple strings, one line after the other
davidenelson 11 months ago
How do you add a 2d array into a text file ? I really need to learn that !!!
thanks !
alimad89 11 months ago
This has been flagged as spam show
Meneltour27 11 months ago
Hey, how do you add multiple records to a file?
Thanks a lot Bucky!
yardenarane 11 months ago 3
how can i add new line to .txt file? and how can i add multiple strings to it?
krechlich 11 months ago
@krechlich add
x.format("\n");
for a new line
wish i helped
Meneltour27 11 months ago
@Meneltour27 ? still not getting it / please expand
mommyjsj 7 months ago
Never mind, solved it. Thanks anyways
ReveanceFX 1 year ago
@ReveanceFX Hey do you have the code for the GUI part of this? I would be interested in seeing it.. sent you a message / friend request
lakers34kb 11 months ago
Ok, I need some help here. I created a GUI to use this. I got it to work (when you enter a sentence and click the button it writes the sentence to a file) but I want to be able to continue and add more lines every time I hit the button, so that I can enter multiple lines in it. Anyone knows how to do this? Everytime I hit the button it overwrites the line that is it it, so using %n won't work. Thanks in advance :)
ReveanceFX 1 year ago
@johnxxx9 that's exactly what I did and thanks to these awesome tuts, managed it in the first go :D
ErichLancaster 1 year ago
After learning all that GUI, it would be better if these tutorials used windows, icons and menus instead of the console.
ErichLancaster 1 year ago
@ErichLancaster We can try doing it by ourselves! Would be a good test of what we have learned
johnxxx9 1 year ago
This has been flagged as spam show
Real benaughty brides are there **benaughtyman.info**
madaraddeumiployolbc 1 year ago
:(
you said that your favorite number was 52.8 in the beginning of your tutorials
which is it? :(
hdanijel 1 year ago
Online marriage service from Asia lushfmlk.info
helaribuska 1 year ago
I WOULD LIKE TO FIND OUT HOW DO YOU CREATE MULTIPLE RECORDS IN THE SAME FILE THE PROGRAM CREATED. "In other words a text file with headers like ID, Name, Account Num etc, and how do you add the various records under the various headings".
Kestojah 1 year ago 2
BUCKYS CHRISTMAS PRESENT 2010 - PLEASE DONATE.
If you are reading this you are probably one of the thousands of people who have been helped by Buckys videos.
Please show your appreciation by donating just $1 (or £1, €1 etc, or more if you want!) before 25th December 2010. It should make for a very happy christmas for him.
Please send donations direct to him by using his paypal link on Youtube or on his new website.
If you think this is a good idea, please vote it up so the word gets round.
jazzninja77 1 year ago 187
@jazzninja77
are you really mad?
you see these ads near video?
thats how he got money, google pays him
nobody does it for free...
devilazpl 1 month ago
Love how you narrate everything you do
xxmannylee1992xx 1 year ago
Just include the Formatter file like this....
import java.util.Formatter;
it's enough for the methods used in the program above.
No need to include java.util.* and also java.lang is already included in every java program.
Chankeypathak 1 year ago
There is soemthing like BufferWriter..... why didnt uyou use that???
revealeddarkness 1 year ago
Greg Bucky Roberts! LOL :D
SkitSophrenia 1 year ago
my files are turning up blank... someone help please?
jdatabean 1 year ago
@jdatabean we're going to need more details than that to help you
Casketreaper 1 year ago
@Casketreaper i did everything right and the file i write to winds up blank but at least it creates a file there i am using netbeans
jdatabean 1 year ago
great tutorials!
LearnTechTv 1 year ago
Thanks a lot Bucky...It really helps and you are a great teacher too..Can you help me with a program that puts data into a .csv file and then reads the data from the .csv file.
After reading the file, the records should be stored in an arrayList.
dhrubajyotitalukdar 1 year ago
Why do you use the methods that you used? Why not use the java.io class's built in methods creating a FileOutputStream, then a PrintStream, and using the println command to enter text in a file. Your method seams a little complex but I am new to java so maybe you could explain to me why I would use your method compared to the one I just explained.
thecreator46 1 year ago
So, if you were to lets say create a game....For the save files, could you use this method at all?
Like instead of %s%s%s then some string in there, could you just create a new variable like name, id, level, or something...and replace them with where you put 20, bucky, roberts?
kyle2120 1 year ago
This has been flagged as spam show
fuck you
Cammie010 1 year ago
How do you Write an INTEGER or Read an Integer from a File ?
theend1245 1 year ago 2
Hi i also have the same question with cottenjet how can i write to the next line the /n is not working for me
greenleafclover16 1 year ago
@greenleafclover16 i think it's \n not /n , ( the one above the enter key) but i'm just guessing
Yekolf 1 year ago
how i go down for write other text line?
CottenJet 1 year ago
How do you use that to write multiple lines in the text file?
azureriot 1 year ago
use %n
CottenJet 1 year ago
@CottenJet
i used %n it works, but it still leaves this black square thing in the text file when i open it with my notebook, how can i fix this?
keeperkai999 1 year ago
bucky you should apply to be a teacher in our university students can understand java more quicker :D
nitecloack 2 years ago
can you write an integer value to a file, is it possible ? how do you do it ? and how do you read an integer value from a file ?
thanx :)
theend1245 2 years ago
I got my file created under the "build" section instead of "JRE System ..." . Do I need to set any preferences somewhere ?
sanjayapps 2 years ago
There's no point in importing java.lang - it's automatically there in every Java program.
cdhagen 2 years ago 6
I didn't really come to these tutorials yet, I'm in the 20's lol, but I'm learning. Oh and I'm not talking about age I'm talking about the tutorials
speed717 2 years ago
Same here, I plan on watching every tutorial, but what i need for an assignment is in the first 20something and the last few bucky just posted (reading, writing, exceptions).
cchapar 2 years ago
I have a file called chinese.txt :P
TheReasonWhyGuy 2 years ago 59
you beat me to it. lol
cchapar 2 years ago
lol...
the saddest thing is, I wasn't just saying that, I really do :D
I studied Chinese a few years ago, and I still have the files from it. XD
TheReasonWhyGuy 2 years ago
@TheReasonWhyGuy OK,我有一个文件叫:中国.txt
Freedom1987ify 6 months ago
Java Programming Tutorial - 80 - Writing to Files
Java 编程教程 - 80 - 写文件
Freedom1987ify 6 months ago
This has been flagged as spam show
im the first :D
Goadfather1973 2 years ago