java中读取中文文件经常出现乱码,是因为java编码的问题,以下是一个简单的类,实现读取中文。
  在用inputstream读取的时候,最好是一次读取多个字节,这样节io操作,提高速度。
		
				package
				 wh;
				import
				 java.io.BufferedReader;
				import
				 java.io.ByteArrayOutputStream;
				import
				 java.io.File;
				import
				 java.io.FileInputStream;
				import
				 java.io.FileReader;
				import
				 java.io.FilterInputStream;
				import
				 java.io.InputStream;
				public
				 
				class
				 Stream
{
    
				public
				 
				static
				 
				void
				 main(String[] args)
    {
        
				try
				
						
        {
            InputStream  r 
				=
				 
				new
				 FileInputStream (
				"
				c:/a.txt
				"
				);
            ByteArrayOutputStream byteout 
				=
				 
				new
				 ByteArrayOutputStream();
            
				byte
				 tmp [] 
				=
				 
				new
				 
				byte
				[
				256
				];
            
				byte
				 context [];
            
				int
				 i 
				=
				 
				0
				;
            
				while
				((i
				=
				r.read(tmp))
				!=-
				1
				)
            {
                byteout.write(tmp);
            }
            context 
				=
				 byteout.toByteArray();
            String str 
				=
				 
				new
				 String(context,
				"
				gb2312
				"
				);
            
				//
				分隔行
				
						
				
				            String stra [] 
				=
				 str.split(
				"
				\n
				"
				);
            
				for
				(
				int
				 n 
				=
				 
				0
				;n
				<
				stra.length;n
				++
				)
            {
                System.out.println(stra[n]
				+
				"
				++++
				"
				);
            }
            
				//
				System.out.println(str);
				
						
				
				        } 
				catch
				 (Exception e)
        {
            
				//
				 TODO: handle exception
				
						
				
				        }
    }
}