62,621
社区成员
发帖
与我相关
我的任务
分享public static void main(String args[])
{
byte buffer[] = new byte[2056];
try
{
FileInputStream fileint = new FileInputStream("dchs.txt");
int bytes = fileint.read(buffer,0,2056);
String str = new String(buffer,0,0,bytes);
System.out.print(str);
}//try
catch(Exception e)
{
String err = e.toString();
System.out.println(err);
}//cathch
}//public static void main(String args[])File file=new File("C:\\dchs.txt");
char[] ch=new char[(int)file.length()];
int len=0;
FileReader fr;
try {
fr = new FileReader(file);
len=fr.read(ch);
System.out.println(new String(ch,0,len));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
public class ReadFileDemo {
public static void main(String args[])
{
byte buffer[] = new byte[2056];
try
{
FileInputStream fileint = new FileInputStream("易中天拼三国.txt");
int i=0;
while(fileint.read(buffer)!=-1){
String str=new String(buffer);
System.out.println(str);
}
}//try
catch(Exception e)
{
e.printStackTrace();
String err = e.toString();
System.out.println(err);
}//cathch
}
}