Examples of FileWriter


Examples of java.io.FileWriter

  }

  public void flush() throws IOException {
    Writer writer = null;
    try {
      writer = new FileWriter(_file);
      _xstream.toXML(_beans, writer);
    } finally {
      if (writer != null) {
        try {
          writer.close();
View Full Code Here

Examples of java.io.FileWriter

    Strings.toString(strbuf, value);
    strbuf.append('\n');
  }

  public static void dumpAttributes(String name, String path) {
    FileWriter writer = null;
    try {
      Set mBeans = null;
      try {
        mBeans = MXWrapper.queryNames(name);
      } catch (Exception exc) {
        logger.log(BasicLevel.ERROR, "DumpAttributes.dumpAttributes, bad name: " + name, exc);
        return;
      }
     
      if (mBeans != null) {
        writer = new FileWriter(path, true);
        StringBuffer strbuf = new StringBuffer();

        for (Iterator iterator = mBeans.iterator(); iterator.hasNext();) {
          String mBean = (String) iterator.next();

          // Get all mbean's attributes
          try {
            List attributes = MXWrapper.getAttributeNames(mBean);
            if (attributes != null) {
              for (int i = 0; i < attributes.size(); i++) {
                String attname = (String) attributes.get(i);
                try {
                  addRecord(strbuf, mBean, attname, MXWrapper.getAttribute(mBean, attname));
                } catch (Exception exc) {
                  logger.log(BasicLevel.ERROR,
                             "DumpAttributes.dumpAttributes, bad attribute : " + mBean + ":" + attname, exc);
                }
              }
            }
            writer.write(strbuf.toString());
            strbuf.setLength(0);
          } catch (Exception exc) {
            logger.log(BasicLevel.ERROR, "DumpAttributes.dumpAttributes", exc);
          }
        }
       
        writer.close();
      }
    } catch (IOException exc) {
      logger.log(BasicLevel.ERROR,
                 "FileMonitoringTimerTask.<init>, cannot open file \"" + path + "\"", exc);
    }
View Full Code Here

Examples of java.io.FileWriter

   */
  public FileMonitoringTimerTask(Timer timer, long period, Properties attlist, String path) {
    super(period, attlist);
   
    try {
      writer = new FileWriter(path, true);
    } catch (IOException exc) {
      logger.log(BasicLevel.ERROR,
                 "FileMonitoringTimerTask.<init>, cannot open file \"" + path + "\"", exc);
    }
    strbuf = new StringBuffer();
View Full Code Here

Examples of java.io.FileWriter

    try {
      File dirlinkFile = new File(dirlink.getLocationURI().getPath());
      Document document = saxReader.read(dirlinkFile);
      Element ele = (Element)document.selectSingleNode("/dirlink/path");    //TODO use statics
      ele.addAttribute("location", linkTarget);                //TODO use statics
        XMLWriter output = new XMLWriter(new FileWriter(dirlinkFile));
        try {
          output.write( document );
        } finally {
          try {
            output.close();
View Full Code Here

Examples of java.io.FileWriter

      PrintWriter pw = null;
     
      try{
        target.getParentFile().mkdirs();
       
        pw = new PrintWriter(new FileWriter(target));
 
        for (int i=0;i<lines.length;i++){
       
          pw.println( lines[i] );
        }
View Full Code Here

Examples of java.io.FileWriter

    } else if (subCommand.equalsIgnoreCase("diag") || subCommand.equalsIgnoreCase("z")) {

      try{
        ci.out.println( "Writing diagnostics to file 'az.diag'" );
       
        FileWriter  fw = new FileWriter( "az.diag" );
       
        PrintWriter  pw = new PrintWriter( fw );
       
        AEDiagnostics.generateEvidence( pw );
       
        pw.flush();
       
        fw.close();
     
      }catch( Throwable e ){
       
        ci.out.println( e );
      }
View Full Code Here

Examples of java.io.FileWriter

   
    if(logFilePrinter == null)
    {
      try
      {
        logFilePrinter = new PrintWriter(new FileWriter(logFile, true));
      } catch (IOException e)
      {
        if (!bLogToFileErrorPrinted) {
         
          // don't just log errors, as it would cause infinite recursion
View Full Code Here

Examples of java.io.FileWriter

        //        if (VISIBLE_PERSPECTIVES.size() > 0) {
        System.out.println("Saving preferences for selected perspectives...");
        sFile = new File(weka.core.WekaPackageManager.PROPERTIES_DIR.toString()
            + File.separator + "VisiblePerspectives.props");
        try {
          FileWriter f = new FileWriter(sFile);
          f.write("weka.gui.beans.KnowledgeFlow.SelectedPerspectives=");
          int i = 0;
          for (String p : VISIBLE_PERSPECTIVES) {
            if (i > 0) {
              f.write(",");
            }
            f.write(p);
            i++;
          }
          f.write("\n");

          f.write("weka.gui.beans.KnowledgeFlow.PerspectiveToolBarVisisble="
              + ((m_configAndPerspectivesVisible) ? "yes" : "no"));
          f.write("\n");
          f.close();
        } catch (Exception ex) {
          System.err.println("[KnowledgeFlow] Unable to save user perspectives preferences");
          ex.printStackTrace();
        }
        //      }
View Full Code Here

Examples of java.io.FileWriter

        log_file.delete();
      }
       
      if ( current_writer == null ){
     
        current_writer = new PrintWriter(new FileWriter( log_file, true ));
      }
     
      current_writer.println( str );
     
      current_writer.flush();
View Full Code Here

Examples of java.io.FileWriter

          log_file.delete();
        }
         
        if ( current_writer == null ){
         
          current_writer = new PrintWriter(new FileWriter( log_file, true ));
        }
       
        for ( StringBuilder str: pending ){
       
          current_writer.println( str );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.