`
收藏列表
标题 标签 来源
解决写文件乱码 io流
	public void writeData(File file){
		StringBuilder builder = new StringBuilder();
		 FileOutputStream fos = null;   
	     OutputStreamWriter writer= null;
            try {
				fos = new FileOutputStream(file) ;
				writer = new OutputStreamWriter(fos,"utf-8");  //制定编码格式  
	            writer.write(builder.toString());   
			} catch (FileNotFoundException e) {
				
			} catch (IOException e) {
				
			} finally{
				  if(writer != null){   
		                try {   
		                    writer.close();   
		                } catch (IOException e) {   
		                	  
		                }   
		            }   
		            if(fos != null){   
		                try {   
		                    fos.close();   
		                } catch (IOException e) {   
		                	  
		                }   
		            }
			}
	}
Global site tag (gtag.js) - Google Analytics