Package java.io

Examples of java.io.FileWriter


          }
         
          if (result != null)
          {
            System.out.println("Ruleflow migrated from version 4.0 to 5.0");
            FileWriter fw = new FileWriter(outFile);
            fw.write(result);
            fw.flush();
            fw.close();
          }
          else
          {
            System.out.println("No Ruleflow Migration Reguired - Ruleflow is version 5.0");
          }
View Full Code Here


    }

    public static void printWorkload(final Collection<? extends Person> personsColl, DataPoolSettings settings) {
        try {
            File file = File.createTempFile("timefinder.workload", "timetable.html");
            FileWriter writer = new FileWriter(file);
            writer.write("<html><head><title>Workload</title>");
            writer.write("</head>");
            writer.write("<body>");

            HtmlPlannerComponent planner = new HtmlPlannerComponent(settings, "person load per slot in percent") {

                @Override
                protected String addTableEntry(Collection<Event> eventsPerSlot) {
                    int persons = 0;
                    // assume disjunct sets of persons
                    for (Event event : eventsPerSlot) {
                        persons += event.getPersons().size();
                    }
                    return Math.round(persons * 100.0f / personsColl.size()) + "%";// + persons + ";" + personsColl.size();
                }
            };
            for (Person p : personsColl) {
                planner.addEvents(p.getEvents());
            }
            writer.write(planner.getTimeTable());
            writer.write("<br/><br/>");

            planner = new HtmlPlannerComponent(settings, "events load per slot in percent");
            for (Person p : personsColl) {
                planner.addEvents(p.getEvents());
            }
            writer.write(planner.getTimeTable());
            writer.write("</body></html>");
            writer.close();
            Helper.openURL(file.toURI());
        } catch (IOException ex) {
            new RuntimeException("Problem while writing timetable of persons!", ex);
        }
    }
View Full Code Here

    }

    public static void printResources(Iterator<? extends Resource> iter, DataPoolSettings settings) {
        try {
            File file = File.createTempFile("timefinder.resources", "timetable.html");
            FileWriter writer = new FileWriter(file);
            writer.write("<html><head><title>Timetable</title></head>");
            writer.write("<body>");
            while (iter.hasNext()) {
                Resource resource = iter.next();
                HtmlPlannerComponent planner = new HtmlPlannerComponent(settings, resource.getName()) {

                    @Override
                    protected String addTableEntry(Collection<Event> eventsPerSlot) {
                        StringBuilder sb = new StringBuilder();
                        for (Event event : eventsPerSlot) {
                            sb.append(toString(event));
                            sb.append("<br/>");
                        }
                        return sb.toString();
                    }
                };
                writer.write("<br/>");
                planner.addEvents(resource.getEvents());
                writer.write(planner.getTimeTable());
                writer.write("<br/>");
                writer.write("<br/>");
            }

            writer.write("</body></html>");
            writer.close();
            Helper.openURL(file.toURI());
        } catch (IOException ex) {
            new RuntimeException("Problem while writing timetable of persons!", ex);
        }
    }
View Full Code Here

        write(reader, f);
    }   
   
    public static void write(final Reader reader, final File f) throws IOException {
      f.getParentFile().mkdirs();
      FileWriter fw = new FileWriter(f);       
        write(fw, reader, -1);  
    }
View Full Code Here

  }

  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

    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

   */
  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

    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

      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

    } 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

TOP

Related Classes of java.io.FileWriter

Copyright © 2015 www.massapicom. 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.