문자열을 파일로 저장하고 싶을 때 사용하면 됩니다.


public void save(String $file_name, String $value){
  
  try{
   InputStream in = new ByteArrayInputStream($value.toString().getBytes("UTF-8"));
   
   FileOutputStream fos = new FileOutputStream($file_name);
   
   BufferedInputStream bis = new BufferedInputStream(in);
   BufferedOutputStream bos = new BufferedOutputStream(fos);
   
   int len=0;
   byte[]buf = new byte[1024];
   while((len=bis.read(buf,0,1024))!=-1){
    bos.write(buf,0,len);
   }
   
   //close
   bos.close();
   bis.close();
   fos.close();
   in.close(); 
  }catch (Exception e) {
   e.printStackTrace();
  }  
 }

+ Recent posts