InputStream的read方法 import java.io.*; public class InputStream {
public static void main(String[] args) throws Exception { byte [] b = "abc1dsa".getBytes(); FileOutputStream out = new FileOutputStream("text1.txt"); out.write(b); out.close();
/*byte buf[] = new byte[1024]; File f = new File("FileSteam.txt"); FileInputStream in = new FileInputStream(f); in.read(buf); System.out.println(new String(buf,0,buf.length));*/
File f = new File("text1.txt"); FileInputStream in = new FileInputStream(f); while((in.read())!=-1);//while(ch!=-1); //这里错了 System.out.println(in.read()); in.close(); }