1、
package com.hcm.tcp;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class input {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File file = new File("d:"+File.separator+"demo.txt");
InputStream input = null;
input = new FileInputStream(file);
byte b[] = new byte[(int)file.length()];//根据文件大小来创建数组
for(int i = 0; i<b.length; i++)
{
b[i] = (byte) input.read();
}
System.out.println(new String(b));
input.close();
}
}