Java读取文件中含有中文的解决办法

   String encoding = "GBK";
   String Content = "";

   String filePath = "E://test//test.inc";
   try

    {   
        File f = new File(filePath);
        if(f.isFile() && f.exists())
        {
              InputStreamReader read = new InputStreamReader(new FileInputStream(f),encoding);
              BufferedReader input = new BufferedReader(read);
     
              StringBuffer buffer = new StringBuffer();   
              String text;   
                       
              while((text = input.readLine()) != null)   

                    buffer.append(text +"/n");   
                       
              Content = buffer.toString();      
        }
      }   
      catch(IOException ioException){  
                System.err.println("File Error!");  

       }

你可能感兴趣的:(java,String,File,buffer,input,encoding)