

Filehand
Presentation
•
Computers
•
9th - 12th Grade
•
Practice Problem
•
Easy
Arasaka Teacher
Used 3+ times
FREE Resource
1 Slide • 16 Questions
1
File
By Arasaka Teacher
2
Reorder
String name = "abc.txt";
File file = new File(name);
System.out.println(file.exists());
try {
// 使用 FileReader 打开文件
使用 BufferedReader 包装 FileReader,提高读取效率
// 用于存储从文件中读取的每一行内容
String line;
// 先读取一行
//条件是什么
{
// 输出当前行
System.out.println(line);
// 读取下一行
line = reader.readLine();
}
} ; // 处理异常
}
FileReader fileReader = new FileReader(file);
BufferedReader reader = new BufferedReader(fileReader);
line = reader.readLine();
while (line != null)
catch (IOException e) {
e.printStackTrace()
3
Drag and Drop
// 4. 将内容写入文件
4
Fill in the Blanks
5
Fill in the Blanks
6
Fill in the Blanks
7
Fill in the Blanks
8
Fill in the Blanks
9
Fill in the Blanks
10
Fill in the Blanks
11
Fill in the Blanks
12
Fill in the Blanks
13
Reorder
Write several lines of text to the file.
DECLARE textLn : STRING
DECLARE myFile : STRING
myFile ← "myText.txt"
REPEAT
OUTPUT "Please enter a line of text"
IF textLn <> ""
THEN
ELSE
ENDIF
OUTPUT "The file contains these lines of text:"
OPEN myFile FOR WRITE
INPUT textLn
WRITEFILE myFile, textLn
CLOSEFILE(myFile)
UNTIL textLn = ""
14
Reorder
This example uses the operations together, to copy all the lines from FileA.txt to FileB.txt,
replacing any blank lines by a line of dashes.
DECLARE LineOfText : STRING
OPENFILE "FileA.txt" FOR READ
OPENFILE "FileB.txt" FOR WRITE
WHILE NOT EOF("FileA.txt")
READFILE "FileA.txt", LineOfText
IF LineOfText = "" THEN
WRITEFILE "FileB.txt", " ----------------------------"
ELSE
WRITEFILE "FileB.txt", LineOfText
ENDIF
ENDWHILE
CLOSEFILE "FileA.txt"
CLOSEFILE "FileB.txt"
15
Fill in the Blanks
16
Reorder
Reorder the following
OUTPUT "The file contains these lines of text:"
REPEAT
OPEN myTextFile FOR READ
READFILE, textIn
OUTPUT textIn
UNTIL EOF(myTextFile)
CLOSEFILE(myTextFile)
17
Reorder
Append a line of text at the end of the file.
DECLARE textIn : STRING
REPEAT
ELSE
OPEN myTextFile FOR APPEND
OUTPUT "Please enter a line of text"
INPUT textIn
IF textIn <> "" THEN
WRITEFILE, textIn
CLOSEFILE(myTextFile)
ENDIF
UNTIL textIn = ""
File
By Arasaka Teacher
Show answer
Auto Play
Slide 1 / 17
SLIDE
Similar Resources on Wayground
10 questions
Graphing Linear Systems
Presentation
•
9th - 12th Grade
13 questions
Data Abstraction
Presentation
•
9th - 12th Grade
15 questions
Media Terminology & Copyright Law 2023
Presentation
•
9th - 12th Grade
12 questions
Asymptotes
Presentation
•
9th - 12th Grade
13 questions
Ilmu Pengetahuan Alam
Presentation
•
KG
11 questions
Elements & Principles of Design
Presentation
•
9th - 12th Grade
13 questions
Clase 1 - Introducción a la Programación
Presentation
•
11th - 12th Grade
14 questions
Topic 3.1 Graphing Polynomial Functions
Presentation
•
9th - 12th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade