Package java.io

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


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

        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

          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

      } catch (IOException e) { }
    }
  }

  public static void save(File dst, HexModel src) throws IOException {
    FileWriter out;
    try {
      out = new FileWriter(dst);
    } catch (IOException e) {
      throw new IOException(Strings.get("hexFileOpenError"));
    }
    try {
      try {
        out.write(RAW_IMAGE_HEADER + "\n");
      } catch (IOException e) {
        throw new IOException(Strings.get("hexFileWriteError"));
      }
      save(out, src);
    } finally {
      try {
        out.close();
      } catch (IOException e) {
        throw new IOException(Strings.get("hexFileWriteError"));
      }
    }
  }
View Full Code Here

        PrintWriter w = new PrintWriter(System.out);
        parser.writeHeader(w);
        parser.writeSource(w);
        w.flush();
        w = new PrintWriter(new FileWriter("bin/test.c"));
        parser.writeHeader(w);
        parser.writeSource(w);
        w.close();

    }
View Full Code Here

        String packageName = clazz.containingPackage().name();
        String dir = destDir + "/" + packageName.replace('.', '/');
        (new File(dir)).mkdirs();
        String fileName = dir + "/" + clazz.name() + ".html";
        String className = getClass(clazz);
        FileWriter out = new FileWriter(fileName);
        PrintWriter writer = new PrintWriter(new BufferedWriter(out));
        writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " +
                "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
        String language = "en";
        writer.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" " +
                "lang=\"" + language + "\" xml:lang=\"" + language + "\">");
        writer.println("<head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /><title>");
        writer.println(className);
        writer.println("</title><link rel=\"stylesheet\" type=\"text/css\" href=\"../../../stylesheet.css\" />");
        writer.println("<script type=\"text/javascript\" src=\"../../../animate.js\"></script>");
        writer.println("</head><body onload=\"openLink();\">");
        writer.println("<table class=\"content\"><tr class=\"content\"><td class=\"content\"><div class=\"contentDiv\">");
        writer.println("<h1>" + className + "</h1>");
        writer.println(formatText(clazz.commentText()) + "<br /><br />");

        // methods
        ConstructorDoc[] constructors = clazz.constructors();
        MethodDoc[] methods = clazz.methods();
        ExecutableMemberDoc[] constructorsMethods = new ExecutableMemberDoc[constructors.length + methods.length];
        System.arraycopy(constructors, 0, constructorsMethods, 0, constructors.length);
        System.arraycopy(methods, 0, constructorsMethods, constructors.length, methods.length);
        Arrays.sort(constructorsMethods, new Comparator<ExecutableMemberDoc>() {
            public int compare(ExecutableMemberDoc a, ExecutableMemberDoc b) {
                // sort static method before non-static methods
                if (a.isStatic() != b.isStatic()) {
                    return a.isStatic() ? -1 : 1;
                }
                return a.name().compareTo(b.name());
            }
        });
//
//
//        Arrays.sort(methods, new Comparator<MethodDoc>() {
//            public int compare(MethodDoc a, MethodDoc b) {
//                // sort static method before non-static methods
//                if (a.isStatic() != b.isStatic()) {
//                    return a.isStatic() ? -1 : 1;
//                }
//                return a.name().compareTo(b.name());
//            }
//        });
        ArrayList<String> signatures = new ArrayList<String>();
        boolean hasMethods = false;
        int id = 0;
        for (int i = 0; i < constructorsMethods.length; i++) {
            ExecutableMemberDoc method = constructorsMethods[i];
            String name = method.name();
            if (skipMethod(method)) {
                continue;
            }
            if (!hasMethods) {
                writer.println("<table class=\"block\"><tr onclick=\"return allDetails()\"><th colspan=\"2\">Methods</th></tr>");
                hasMethods = true;
            }
            String type = getTypeName(method.isStatic(), false, getReturnType(method));
            writer.println("<tr id=\"__"+id+"\" onclick=\"return on("+ id +")\">");
            writer.println("<td class=\"return\">" + type + "</td><td class=\"method\">");
            Parameter[] params = method.parameters();
            StringBuilder buff = new StringBuilder();
            StringBuilder buffSignature = new StringBuilder(name);
            buff.append('(');
            for (int j = 0; j < params.length; j++) {
                if (j > 0) {
                    buff.append(", ");
                }
                buffSignature.append('_');
                Parameter param = params[j];
                boolean isVarArgs = method.isVarArgs() && j == params.length - 1;
                String typeName = getTypeName(false, isVarArgs, param.type());
                buff.append(typeName);
                buffSignature.append(StringUtils.replaceAll(typeName, "[]", "-"));
                buff.append(' ');
                buff.append(param.name());
            }
            buff.append(')');
            if (isDeprecated(method)) {
                name = "<span class=\"deprecated\">" + name + "</span>";
            }
            String signature = buffSignature.toString();
            while (signatures.size() < i) {
                signatures.add(null);
            }
            signatures.add(i, signature);
            writer.println("<a id=\"" + signature + "\" href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
            String firstSentence = getFirstSentence(method.firstSentenceTags());
            if (firstSentence != null) {
                writer.println("<div class=\"methodText\">" + formatText(firstSentence) + "</div>");
            }
            writer.println("</td></tr>");
            writer.println("<tr onclick=\"return off("+ id +")\" class=\"detail\" id=\"_"+id+"\">");
            writer.println("<td class=\"return\">" + type + "</td><td>");
            writeMethodDetails(writer, clazz, method, signature);
            writer.println("</td></tr>");
            id++;
        }
        if (hasMethods) {
            writer.println("</table>");
        }

        // field overview
        FieldDoc[] fields = clazz.fields();
        if (clazz.interfaces().length > 0) {
            fields = clazz.interfaces()[0].fields();
        }
        Arrays.sort(fields, new Comparator<FieldDoc>() {
            public int compare(FieldDoc a, FieldDoc b) {
                return a.name().compareTo(b.name());
            }
        });
        int fieldId = 0;
        for (FieldDoc field : fields) {
            if (skipField(clazz, field)) {
                continue;
            }
            String name = field.name();
            String text = field.commentText();
            if (text == null || text.trim().length() == 0) {
                addError("Undocumented field (" + clazz.name() + ".java:" + field.position().line() + ") " + name);
            }
            if (text != null && text.startsWith("INTERNAL")) {
                continue;
            }
            if (fieldId == 0) {
                writer.println("<br /><table><tr><th colspan=\"2\">Fields</th></tr>");
            }
            String type = getTypeName(true, false, field.type());
            writer.println("<tr><td class=\"return\">" + type + "</td><td class=\"method\">");
            String constant = field.constantValueExpression();

            // add a link (a name) if there is a <code> tag
            String link = getFieldLink(text, constant, clazz, name);
            writer.print("<a href=\"#" + link + "\">" + name + "</a>");
            if (constant == null) {
                writer.println();
            } else {
                writer.println(" = " + constant);
            }
            writer.println("</td></tr>");
            fieldId++;
        }
        if (fieldId > 0) {
            writer.println("</table>");
        }

        // field details
        Arrays.sort(fields, new Comparator<FieldDoc>() {
            public int compare(FieldDoc a, FieldDoc b) {
                String ca = a.constantValueExpression();
                if (ca == null) {
                    ca = a.name();
                }
                String cb = b.constantValueExpression();
                if (cb == null) {
                    cb = b.name();
                }
                return ca.compareTo(cb);
            }
        });
        for (FieldDoc field : fields) {
            writeFieldDetails(writer, clazz, field);
        }

        writer.println("</div></td></tr></table></body></html>");
        writer.close();
        out.close();
    }
View Full Code Here

            for (String model : models) {
                Matcher m = p.matcher(model);
                if (m.find()) {
                    String className = m.group().substring("class".length()).trim();
                    File classFile = new File(parentFile, className + ".java");
                    Writer o = new FileWriter(classFile, false);
                    PrintWriter writer = new PrintWriter(new BufferedWriter(o));
                    writer.write(model);
                    writer.close();
                    System.out.println("Generated " + classFile.getAbsolutePath());
                }
View Full Code Here

            Strings.get("fileExistsTitle"),
            0, JOptionPane.QUESTION_MESSAGE, null,
            options, options[0]);
          if (option == 0) {
            try {
              FileWriter delete = new FileWriter(file);
              delete.close();
            } catch (IOException e) { }
          } else if (option == 1) {
            // do nothing
          } else {
            return;
View Full Code Here

            Localizer.getMessage("jspc.webinc.insertEnd");

        BufferedReader reader = new BufferedReader(new FileReader(webXml));
        BufferedReader fragmentReader =
            new BufferedReader(new FileReader(webxmlFile));
        PrintWriter writer = new PrintWriter(new FileWriter(webXml2));

        // Insert the <servlet> and <servlet-mapping> declarations
        int pos = -1;
        String line = null;
        while (true) {
View Full Code Here

TOP

Related Classes of java.io.FileWriter

Copyright © 2018 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.