Package java.io

Examples of java.io.PrintWriter


                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());
                }
            }
        } catch (IOException io) {
            throw DbException.convertIOException(io, "could not generate model").getSQLException();
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) {
            line = reader.readLine();
            if (line == null) {
                break;
            }
            // Skip anything previously generated by JSPC
            if (line.indexOf(insertStartMarker) >= 0) {
                while (true) {
                    line = reader.readLine();
                    if (line == null) {
                        return;
                    }
                    if (line.indexOf(insertEndMarker) >= 0) {
                        line = reader.readLine();
                        line = reader.readLine();
                        if (line == null) {
                            return;
                        }
                        break;
                    }
                }
            }
            for (int i = 0; i < insertBefore.length; i++) {
                pos = line.indexOf(insertBefore[i]);
                if (pos >= 0)
                    break;
            }
            if (pos >= 0) {
                writer.print(line.substring(0, pos));
                break;
            } else {
                writer.println(line);
            }
        }

        writer.println(insertStartMarker);
        while (true) {
            String line2 = fragmentReader.readLine();
            if (line2 == null) {
                writer.println();
                break;
            }
            writer.println(line2);
        }
        writer.println(insertEndMarker);
        writer.println();

        for (int i = 0; i < pos; i++) {
            writer.print(" ");
        }
        writer.println(line.substring(pos));

        while (true) {
            line = reader.readLine();
            if (line == null) {
                break;
            }
            writer.println(line);
        }
        writer.close();

        reader.close();
        fragmentReader.close();

        FileInputStream fis = new FileInputStream(webXml2);
View Full Code Here

    }

    private void initServletContext() {
        try {
            context =new JspCServletContext
                (new PrintWriter(System.out),
                 new URL("file:" + uriRoot.replace('\\','/') + '/'));
            tldLocationsCache = new TldLocationsCache(context, true);
        } catch (MalformedURLException me) {
            System.out.println("**" + me);
        }
View Full Code Here

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

        BufferedReader reader = new BufferedReader(openWebxmlReader(webXml));
        BufferedReader fragmentReader = new BufferedReader(
                openWebxmlReader(new File(webxmlFile)));
        PrintWriter writer = new PrintWriter(openWebxmlWriter(webXml2));

        // Insert the <servlet> and <servlet-mapping> declarations
        boolean inserted = false;
        int current = reader.read();
        while (current > -1) {
            if (current == '<') {
                String element = getElement(reader);
                if (!inserted && insertBefore.contains(element)) {
                    // Insert generated content here
                    writer.println(insertStartMarker);
                    while (true) {
                        String line = fragmentReader.readLine();
                        if (line == null) {
                            writer.println();
                            break;
                        }
                        writer.println(line);
                    }
                    writer.println(insertEndMarker);
                    writer.println();
                    writer.write(element);
                    inserted = true;
                } else if (element.equals(insertStartMarker)) {
                    // Skip the previous auto-generated content
                    while (true) {
                        current = reader.read();
                        if (current < 0) {
                            throw new EOFException();
                        }
                        if (current == '<') {
                            element = getElement(reader);
                            if (element.equals(insertEndMarker)) {
                                break;
                            }
                        }
                    }
                    current = reader.read();
                    while (current == '\n' || current == '\r') {
                        current = reader.read();
                    }
                    continue;
                } else {
                    writer.write(element);
                }
            } else {
                writer.write(current);
            }
            current = reader.read();
        }
        writer.close();

        reader.close();
        fragmentReader.close();

        FileInputStream fis = new FileInputStream(webXml2);
View Full Code Here

    }

    protected void initServletContext() {
        try {
            context =new JspCServletContext
                (new PrintWriter(System.out),
                 new URL("file:" + uriRoot.replace('\\','/') + '/'));
            tldLocationsCache = TldLocationsCache.getInstance(context);
        } catch (MalformedURLException me) {
            System.out.println("**" + me);
        }
View Full Code Here

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

        BufferedReader reader = new BufferedReader(openWebxmlReader(webXml));
        BufferedReader fragmentReader = new BufferedReader(
                openWebxmlReader(new File(webxmlFile)));
        PrintWriter writer = new PrintWriter(openWebxmlWriter(webXml2));

        // Insert the <servlet> and <servlet-mapping> declarations
        boolean inserted = false;
        int current = reader.read();
        while (current > -1) {
            if (current == '<') {
                String element = getElement(reader);
                boolean found = false;
                if (!inserted) {
                    for (String before : insertBefore) {
                        if (element.equals(before)) {
                            found = true;
                            break;
                        }
                    }
                }
                if (found) {
                    // Insert generated content here
                    writer.println(insertStartMarker);
                    while (true) {
                        String line = fragmentReader.readLine();
                        if (line == null) {
                            writer.println();
                            break;
                        }
                        writer.println(line);
                    }
                    writer.println(insertEndMarker);
                    writer.println();
                    writer.write(element);
                    inserted = true;
                } else if (element.equals(insertStartMarker)) {
                    // Skip the previous auto-generated content
                    while (true) {
                        current = reader.read();
                        if (current < 0) {
                            throw new EOFException();
                        }
                        if (current == '<') {
                            element = getElement(reader);
                            if (element.equals(insertEndMarker)) {
                                break;
                            }
                        }
                    }
                    current = reader.read();
                    while (current == '\n' || current == '\r') {
                        current = reader.read();
                    }
                    continue;
                } else {
                    writer.write(element);
                }
            } else {
                writer.write(current);
            }
            current = reader.read();
        }
        writer.close();

        reader.close();
        fragmentReader.close();

        FileInputStream fis = new FileInputStream(webXml2);
View Full Code Here

    }

    protected void initServletContext() {
        try {
            context =new JspCServletContext
                (new PrintWriter(System.out),
                 new URL("file:" + uriRoot.replace('\\','/') + '/'));
            tldLocationsCache = new TldLocationsCache(context, true);
        } catch (MalformedURLException me) {
            System.out.println("**" + me);
        }
View Full Code Here

          if (rout != null)
            throw new IllegalStateException(
                "Already was returned as servlet output stream");
          String encoding = getCharacterEncoding();
          if (encoding != null)
            pw = new PrintWriter(new OutputStreamWriter(out,
                encoding));
          else
            pw = new PrintWriter(out);
        }
      }
      return pw;
    }
View Full Code Here

          .info("hello3 req encoding [{}]", request
              .getCharacterEncoding());
      log.info("hello3 res encoding [{}]", response
          .getCharacterEncoding());
      response.setHeader("Content-Type", "text/plain; charset=utf-8");
      PrintWriter writer = response.getWriter();
      writer.print("测试hello3");
      writer.close();
    } catch (IOException e) {
      e.printStackTrace();
    }

    return null;
View Full Code Here

  }

  public void log(String message, Throwable throwable) {
    if (throwable != null) {
      StringWriter sw;
      PrintWriter pw = new PrintWriter(sw = new StringWriter());
      throwable.printStackTrace(pw);
      // printCauses(throwable, pw);
      message = message + '\n' + sw;
    }
    log(message);
View Full Code Here

TOP

Related Classes of java.io.PrintWriter

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.