DataInputStream fdi=new DataInputStream(new FileInputStream(file));
通过这个方式来读css文件,while((temp_line=fdi.readLine())!=null){}
里面的汉字乱码了..这是为什么..css文件是以gbk方式编码的.

解决方案 »

  1.   

    css 中为什么要写中文呢?是注释吗?
    我不懂,问问。
      

  2.   

    用一个reader读。初始化reader的时候,指定编码方式
      

  3.   

    BufferedReader br = new BufferedReader(new FileReader("a.txt"));
    String str;
    while((str=br.readLine())!=null){
    System.out.println(str);
    }
    不要用DataInputStream来readLine,看下面
    -----------------------------------------------------------------
    readLine
    @Deprecated
    public final String readLine()
                          throws IOExceptionDeprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form: 
         DataInputStream d = new DataInputStream(in);
     with: 
         BufferedReader d
              = new BufferedReader(new InputStreamReader(in));