FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaSE/JavaIO/StringFile_t.java at master · goder/JavaSE · GitHub
goder
JavaSE
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaSE
/
JavaIO
/
StringFile_t.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (39 loc) · 889 Bytes
Breadcrumbs
JavaSE
/
JavaIO
/
StringFile_t.java
Copy path
File metadata and controls
45 lines (39 loc) · 889 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
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* 功能:文件字符流,读取文件,写出文件,每次读写一个字符
*/
package
com
.
bj
.
io
;
import
java
.
io
.*;
public
class
StringFile_t
{
public
static
void
main
(
String
[]
args
) {
// 文件取出字符流对象(输入流)
FileReader
fr
=
null
;
//写入文件(输出流)
FileWriter
fw
=
null
;
try
{
//创建fr对象
fr
=
new
FileReader
(
"D:/www/test.txt"
);
//创建fw对象
fw
=
new
FileWriter
(
"D:/www/test_copy.txt"
);
//读入到内存
char
c
[]=
new
char
[
1024
];
//读入字符计数
int
count
=
0
;
///循环读取,read(),当读取到最后会返回-1,正常返回读取的字符数
while
(-
1
!=(
count
=
fr
.
read
(
c
))){
String
s
=
new
String
(
c
,
0
,
count
);
System
.
out
.
println
(
s
);
fw
.
write
(
c
,
0
,
count
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
finally
{
try
{
fr
.
close
();
fw
.
close
();
}
catch
(
IOException
e
) {
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL