Join Peggy Fisher for an in-depth discussion in this video Implementing file operations, part of Learning Java.
- Up until now, we've been reading data…directly from the console using the Scanner class.…Now let's see how we can read data from a file.…By importing the libraries included, using the wildcard,…java.io.*…This allows us to read from a file, write to a file…or even create a new file.…In this program, we will read possible replies…to a random question asked by the user:…A type of "fortuneTeller" program.…To open and read from a file, we need to follow these steps:…Step One is to create a file object…that specifies the filename, including the extension.…
Right here, I have "File_InputFile".…"InputFile" is my variable name, equals "new_File",…and the name of my file is "answers.txt"…Let's take a quick look at that file.…Right now, it has 10 random answers.…These are the answers that the program will use…to reply to the customer's question.…I do wanna point out that the file…has to be in the same location as the "build.xml" file.…Okay, let's go back to our program.…
The next thing I do is create an arraylist…called "answers" of type = [String]…
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.