如题

解决方案 »

  1.   

    用FileInputStream类读出字节数组buff,然后
    String text = new String(buff, "GBK");
    如果你的文件是UTF-8编码的就将GBK改为UTF-8
      

  2.   

    从 InputStream 来的都是字节流,必须进行转码
      

  3.   

    》从 InputStream 来的都是字节流,必须进行转码怎么转啊?
      

  4.   

    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;public class tetawer { /**
     * @param args
     */
    public static void main(String[] args) {
    try {
    FileInputStream f = new FileInputStream("test.txt");
    byte[] b=new byte[100];
    f.read(b);
    String s = new String(b, "UTF-8");
    System.out.println(s);

    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }}