天天看點

filehelper java_JAVA中FileHelper的一個用法

public boolean writeXML(String content, String filename)    {           String savepath;        FileOutputStream fout;//        log.info("content:"+content+" filename:"+filename+" writeDir:"+writeDir);        savepath = (new StringBuilder(String.valueOf(writeDir))).append(File.separatorChar).append(filename).toString();        fout = null;        if(content == null)            return false;        File file = new File(writeDir);        try        {         if(!file.exists()){          file.mkdirs();         }            fout = new FileOutputStream(savepath);            byte buffer[] = content.getBytes();            fout.write(buffer);           // break MISSING_BLOCK_LABEL_111;        }        catch(Exception e)        {            e.printStackTrace();        }        if(fout != null)            try            {                fout.close();            }            catch(IOException e)            {                return false;            }       // return false;       // Exception exception;       // exception;        if(fout != null)            try            {                fout.close();            }            catch(IOException e)            {                return false;            }        //throw exception;        if(fout != null)            try            {                fout.close();            }            catch(IOException e)            {                return false;            }        return true;    }