RUVIDEO
Поделитесь видео 🙏

Java Programming Tutorial 80 Writing to Files

More intensive courses : http://grow-book.blogspot.com/
Abstract video content

what is going on guys is Bucky and welcome to your 80th jobs tutorial in

this storm going to you guys how to add data to your files so in the last

tutorial we pretty much learned how to create an empty file not that useful so

let's go ahead and put something in it in this story and what I want to get an

agent here

good i got it alright so let's go ahead and in for a couple things you need to

import Java diode and let's go ahead and for everything from there and as you can

see i made a separate class outside my main class and I just named it create

file because that's where we're going to be doing creating files

that's my name to that so next let's go ahead and put java . laying we need some

crap from there

and lastly let's go ahead and import java.util i'm not exactly sure where

we're going to building the story but this should cover everything

so without further ado let me think what i want to do first

well the first thing we need to do is do a private formatter variable and i'm

going to name an X as usual and what this is going to do is hold a formatter

object and let's go ahead and make a method to pretty much create and open a

file so let's go ahead and put public void in or just name it

open-file you name it whatever you want it's a don't take any parameters because

just going to open file now in this method what we want to do we got and

have our try and catch block like always

so let's go ahead and try and set X equal to Nu for matter object in go

ahead and write a file name um make sure you write one that you don't already

have a file or else you're going to overwrite it so I don't have a file

called like chinese that text you probably don't either so you can use

that so go ahead and try and set this file equal to x

if you can't let's just go ahead and catch exception so catch exception e and

this pretty much means if you get in air

what do you want to do justice system out print line just put you have an err

err no error there we go

alright so now when we ever we call this method open file is pretty much just

going to set X equal to this file is pretty much just going to give us a file

so we can use so now we have a file that we can use

so what we want to do that well we want to add a record to it so let's go ahead

and put public void add the records and go ahead and this is taking the

parameters either and adding records is the easiest thing in the world

all you need to do is put the file you want added to which is X because

remember we set equal Chinese that text and what you do is the method is format

and this pretty much like printf for files and now again how familiar is this

the format and the arguments so for the format let's let since your three

strings the first one say we're making like a user account the first one will

be the ID number so we'll pull like 20 my favorite number and the second one

will be my first name which is Bucky and the third piece of data will be Roberts

which is my last name so it looks good right there

so now what this is going to do is insert three elements in the same line

is going to say 20 Bucky Roberts it's going to insert that in our file

whenever we call this method add records in the last thing that we want to do is

very method close the file so go ahead and write public void closed file or

name of whatever you want but that's pretty easy to remember

and why do we need but i'll show you guys what the thing is

x close and closes built-in method so that's why we can use this and that's

why we needed include all these so we can use this close method but now let me

tell you guys why we need to close this file

it's pretty much like housekeeping thing whenever we exit our program windows

usually and I say usually closes our file from writing so nothing else can

write in it but sometimes remember every operating system is different sometimes

depending on your program it can leave the file open it can lead to samirs so

you always want to close your files its good programming you always want to do

it i mean you can probably get away with not doing it but if you ever get jobs

jump programmer they are going to be po2 you forget to close your files

it's probably going to cause some errors later down the road so we pretty much

recap talk about something different now pretty much got three methods in here we

need to open the file we need to add some records in it and then we need to

close the file because we're done with that we don't want anyone else messing

with it so go ahead and in your main or whatever your main method is just go

ahead and well we don't need to include anything but we do need is to create an

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Programming Tutorial 80 Writing to Files», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.