FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Lessons4JavaSE/src/unit06/TestDataStream.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
/
TestDataStream.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (25 loc) · 1 KB
Breadcrumbs
Lessons4JavaSE
/
src
/
unit06
/
TestDataStream.java
Copy path
File metadata and controls
31 lines (25 loc) · 1 KB
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
package
unit06
;
import
java
.
io
.*;
public
class
TestDataStream
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// Create an output stream for file temp.dat
DataOutputStream
output
=
new
DataOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
"temp.dat"
)));
// Write student test scores to the file
output
.
writeUTF
(
"John"
);
output
.
writeDouble
(
85.5
);
output
.
writeUTF
(
"Jim"
);
output
.
writeDouble
(
185.5
);
output
.
writeUTF
(
"George"
);
output
.
writeDouble
(
105.25
);
// Close output stream
output
.
close
();
// Create an input stream for file temp.dat
DataInputStream
input
=
new
DataInputStream
(
new
BufferedInputStream
(
new
FileInputStream
(
"temp.dat"
)));
// Read student test scores from the file
System
.
out
.
println
(
input
.
readUTF
() +
" "
+
input
.
readDouble
());
System
.
out
.
println
(
input
.
readUTF
() +
" "
+
input
.
readDouble
());
System
.
out
.
println
(
input
.
readUTF
() +
" "
+
input
.
readDouble
());
}
}
Back
|
FazBrowse Home
|
New Git URL