在MyEclipse控制台输出问题
我的代码在控制台输出怎么是这样的?代码在后面packagecom.bjpowernode.io;importjava.io.FileInputStream;importj...
我的代码在控制台输出怎么是这样的? 代码在后面
pack
age
com.
bjpo
wern
ode.
io;
i
mpor
t ja
va.i
o.Fi
leIn
putS
trea
m;
impo
rt j
ava.
io.I
OExc
epti
on;
p
ubli
c cl
ass
File
Inpu
tStr
eamt
est
{
publ
ic s
tati
c vo
id m
ain(
Stri
ng[]
arg
s) {
File
Inpu
tStr
eam
fis
= nu
ll;
t
ry{
fis
= ne
w Fi
leIn
putS
trea
m("s
rc/c
om/b
jpow
erno
de/i
o/Fi
leIn
putS
trea
mtes
t.ja
va")
;
b
yte[
] by
tes
= ne
w by
te[4
];
i
nt r
eadC
ount
;
wh
ile(
(rea
dCou
nt =
fis
.rea
d(by
tes)
) !=
-1)
{
Syst
em.o
ut.p
rint
ln(n
ew S
trin
g(by
tes,
0,re
adCo
unt)
);
}
}ca
tch
(Exc
epti
on e
) {
e.pr
intS
tack
Trac
e();
}fin
ally
{
if
(fis
!=
null
) {
try
{
fis.
clos
e();
}c
atch
(IOE
xcep
tion
e)
{
e.pr
intS
tack
Trac
e();
}
}
}
}
}
代码
package com.bjpowernode.io;
import java.io.FileInputStream;
import java.io.IOException;
public class FileInputStreamtest {
public static void main(String[] args) {
FileInputStream fis = null;
try{
fis = new FileInputStream("src/com/bjpowernode/io/FileInputStreamtest.java");
byte[] bytes = new byte[4];
int readCount;
while((readCount = fis.read(bytes)) != -1) {
System.out.println(new String(bytes,0,readCount));
}
}catch (Exception e) {
e.printStackTrace();
}finally{
if(fis != null) {
try{
fis.close();
}catch(IOException e) {
e.printStackTrace();
}
}
}
}
} 展开
pack
age
com.
bjpo
wern
ode.
io;
i
mpor
t ja
va.i
o.Fi
leIn
putS
trea
m;
impo
rt j
ava.
io.I
OExc
epti
on;
p
ubli
c cl
ass
File
Inpu
tStr
eamt
est
{
publ
ic s
tati
c vo
id m
ain(
Stri
ng[]
arg
s) {
File
Inpu
tStr
eam
fis
= nu
ll;
t
ry{
fis
= ne
w Fi
leIn
putS
trea
m("s
rc/c
om/b
jpow
erno
de/i
o/Fi
leIn
putS
trea
mtes
t.ja
va")
;
b
yte[
] by
tes
= ne
w by
te[4
];
i
nt r
eadC
ount
;
wh
ile(
(rea
dCou
nt =
fis
.rea
d(by
tes)
) !=
-1)
{
Syst
em.o
ut.p
rint
ln(n
ew S
trin
g(by
tes,
0,re
adCo
unt)
);
}
}ca
tch
(Exc
epti
on e
) {
e.pr
intS
tack
Trac
e();
}fin
ally
{
if
(fis
!=
null
) {
try
{
fis.
clos
e();
}c
atch
(IOE
xcep
tion
e)
{
e.pr
intS
tack
Trac
e();
}
}
}
}
}
代码
package com.bjpowernode.io;
import java.io.FileInputStream;
import java.io.IOException;
public class FileInputStreamtest {
public static void main(String[] args) {
FileInputStream fis = null;
try{
fis = new FileInputStream("src/com/bjpowernode/io/FileInputStreamtest.java");
byte[] bytes = new byte[4];
int readCount;
while((readCount = fis.read(bytes)) != -1) {
System.out.println(new String(bytes,0,readCount));
}
}catch (Exception e) {
e.printStackTrace();
}finally{
if(fis != null) {
try{
fis.close();
}catch(IOException e) {
e.printStackTrace();
}
}
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询