FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Lessons4JavaSE/src/unit06/TestFileReader.java at master · AlohaWorld/Lessons4JavaSE · GitHub
AlohaWorld
/
Lessons4JavaSE
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
19
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Lessons4JavaSE
/
src
/
unit06
/
TestFileReader.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (29 loc) · 925 Bytes
Breadcrumbs
Lessons4JavaSE
/
src
/
unit06
/
TestFileReader.java
Copy path
File metadata and controls
32 lines (29 loc) · 925 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package
unit06
;
import
java
.
io
.*;
public
class
TestFileReader
{
public
static
void
main
(
String
[]
args
) {
FileReader
input
=
null
;
try
{
/*
* BE AWARE! The file "temp.txt" is located at the root dir of current
* project. Do NOT try to find it under src/ or bin/!
*/
// Create an input stream
input
=
new
FileReader
(
"temp.txt"
);
int
code
;
// Repeatedly read a character and display it on the console
while
((
code
=
input
.
read
()) != -
1
)
System
.
out
.
print
((
char
)
code
);
}
catch
(
FileNotFoundException
ex
) {
System
.
out
.
println
(
"File temp.txt does not exist"
);
}
catch
(
IOException
ex
) {
ex
.
printStackTrace
();
}
finally
{
try
{
input
.
close
();
// Close the stream
}
catch
(
IOException
ex
) {
ex
.
printStackTrace
();
}
// end try
}
// end finally
}
// end main
}
Back
|
FazBrowse Home
|
New Git URL