package cn.imcore.cd;import java.io.*;
public class TestStream {
public static void main(String[] args)
{
File a = new File("tmp/file1.txt");
if(!a.exists())
{
try
{
a.createNewFile();
}
catch (IOException e)
{
e.printStackTrace();
}
InputStream is = null;
try
{
is = new FileInputStream(a);
int tmp = is.read();
while(tmp != -1)
{
System.out.print((char)tmp);
tmp = is.read();
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if(is != null)
{
try
{
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
}
代码看的难受!
public class TestStream {
public static void main(String[] args)
{
File a = new File("tmp/file1.txt");
if(!a.exists())
{
try
{
a.createNewFile();
}
catch (IOException e)
{
e.printStackTrace();
}
InputStream is = null;
try
{
is = new FileInputStream(a);
int tmp = is.read();
while(tmp != -1)
{
System.out.print((char)tmp);
tmp = is.read();
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if(is != null)
{
try
{
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
}
代码看的难受!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货