课程: Java for All Platforms: Desktop, Web, and Mobile Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Read data from a file - Java教程
课程: Java for All Platforms: Desktop, Web, and Mobile Development
Read data from a file
- [Instructor] Another important feature of a programming language is the ability to read data from a file. So let's take a look at how that works with Java. So I'm going to create a folder for external assets and by that I mean assets we can load into our code that don't go inside of our packages. Like this one right here. And we can do that by right clicking our project and choosing New, Directory. I'll call this assets. And then I'm going to right click assets and choose New, File. We'll call this example.txt. And then write some text in here on multiple lines. Just like that. Save the file and head back to your code. In the code, we're going to load this using the file class. So create an instance of the file class, which is in the java.io package. And then we'll call this file with a lowercase f and we'll set it equal to a new File, passing in the path of the file. The path is relative to the root of our…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
(已锁定)
Variables4 分钟 4 秒
-
(已锁定)
Functions4 分钟 40 秒
-
(已锁定)
Arrays and lists6 分钟 17 秒
-
(已锁定)
Conditional statements3 分钟 45 秒
-
(已锁定)
Classes and packages6 分钟 14 秒
-
(已锁定)
Input and output2 分钟 26 秒
-
(已锁定)
Read data from a file4 分钟 12 秒
-
(已锁定)
Handle Java errors3 分钟 26 秒
-
(已锁定)
Challenge: Sum of a list54 秒
-
(已锁定)
-
-
-
-
-