2 lzllzllhl lzllzllhl 于 2016.03.21 10:18 提问

inputstream和Fileinputstream一起运行为什么读不出来 代码如下:

package l0321;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Lzl {

public static void main(String[] args) throws IOException {
    String path = "F://iotest";
    File file = new File(path);
    boolean mkdirs = file.mkdirs();
    System.out.println(mkdirs);
    File file2 = new File(path, "IO.txt");
    boolean create = file2.createNewFile();
    System.out.println(create);
    Lzl lzl = new Lzl();
    lzl.fun(file2);
    lzl.fun2(file2);
}
public void fun(File f) throws IOException{
    fun2(f);
    System.out.println("请输入:");
    InputStream input = System.in;
    byte [] bs = new byte[1024];
    int i = input.read(bs);
    String ss = new String(bs,0,i);

    //System.out.println(i);
    input.close();
    OutputStream output = System.out;
    output.write(bs,0,i);
    output.flush();
    output.close();

}
public void fun2(File a) throws IOException{
    FileInputStream fileInput = new FileInputStream(a);
    byte[]bb = new byte[4096];
    int ii = fileInput.read(bb);
    String string = new String(bb, 0, ii);
    System.out.println(string);
}

}

1个回答

sinat_34367776
sinat_34367776   2016.03.21 10:29

??????????

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!