Package java.io

Examples of java.io.BufferedWriter


//    }

    protected void printPage(byte[] page, int pg, String fname) {

        try {
            BufferedWriter ow = new BufferedWriter(new PrintWriter(new FileOutputStream(fname, true)), page.length);
            ow.write(" txnID=" + Integer.toHexString(txnId) + " type=" + types[type]);
            ow.newLine();
            String s = ByteTool.toHexString(0, page, 0, page.length);
            ow.write(s, 0, s.length());
            ow.newLine();
            ow.flush();
            ow.close();

        } catch (Exception e) {
            logger.debug(e);
        }
    }
View Full Code Here


    }

    void recordPage(Lsn lsn, int p, byte page[]) {
        String dir = "D:\\working\\sampledb\\ChaiDB\\datalog\\page\\";
        try {
            BufferedWriter out = new BufferedWriter(new PrintWriter(new FileOutputStream(dir + Integer.toHexString(p), true)));
            out.write("prevlsn=" + lsn.toHexString() + "\ttxn=" + Integer.toHexString(txnId) + "\t" + types[type] + "\n\r" + ByteTool.toHexString(2, page, 0, page.length) + "\n\r");
            out.close();
        } catch (Exception e) {
            logger.debug(e);
        }
    }
View Full Code Here

  public static void print(final RenderBox box)
  {
    try
    {
      final File file = File.createTempFile("model-dump-", ".txt");
      final BufferedWriter writer = new BufferedWriter(new FileWriter(file));
      printBox(writer, box, 0);
      writer.close();
    }
    catch (Exception e)
    {
      throw new Error();
    }
View Full Code Here

            try {
                if(!oFile.exists()){
                    oFile.createNewFile();
                }
                if (oFile.canWrite()) {
                    outWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(oFile)));
                }
            } catch (FileNotFoundException e) {
                //Use logger to track SEVERE message.
                logger.log(Level.WARNING, "Can not find file " + outputFile + ", print outputs to void.", e);
            } catch (IOException e) {
                //Use logger to track SEVERE message.
                logger.log(Level.WARNING, "Can not create output file " + outputFile + ", print outputs to void.", e);
            }
        }
        if (errFile != null) {
            File eFile = new File(errFile);
            try {
                if(!eFile.exists()){
                    eFile.createNewFile();
                }
                if (eFile.canWrite()) {
                    errWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(eFile)));
                }
            } catch (FileNotFoundException e) {
                //Use logger to track SEVERE message.
                logger.log(Level.WARNING, "Can not find file " + errFile + ", print errors to void.", e);
            } catch (IOException e) {
View Full Code Here

   *                   that    are not <code>Strings</code>.
   * @exception        NullPointerException  if <code>out</code> is null.
   */
  public synchronized void store(OutputStream out, String header)
    throws IOException {
    BufferedWriter awriter;
    awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));

    for (int i = 0; i < _infoList.size(); i++) {
      Info info = (Info) _infoList.get(i);

      if (info._type == Info.COMMENT) {
        // Add a comment line
        awriter.write(info._value);
        awriter.newLine();

      } else if (info._type == Info.EMPTY_LINE) {
        // Add a empty line
        awriter.newLine();
      } else if (info._type == Info.MASTER_LINE) {
                awriter.write(Info.IMPORT_FILE_PREFIX+ " "+info._value);
                awriter.newLine();
            } else {
        // Add a property (key + value) line
        String key = info._value;

        String val = (String) get(key);
        key = saveConvert(key, true);

        /* No need to escape embedded and trailing spaces for value,
         * hence pass false to flag.
         */
        val = saveConvert(val, false);

        awriter.write(key + "=" + val);
        awriter.newLine();
      }
    }
    awriter.flush();
  }
View Full Code Here

  FileInputStream fin = new FileInputStream(srcLogFile);
  FileOutputStream fout = new FileOutputStream(outLogFile);
 
  BufferedReader r = new BufferedReader(new InputStreamReader(fin,"UTF-8"));
 
  BufferedWriter w = new BufferedWriter(new OutputStreamWriter(fout,"UTF-8"));
 
  while(true){
    String line = r.readLine();
   
    if (line == null){
      break;
    }
   
    int idx = line.indexOf("REQ: ");
    if (idx>=0){
      line = line.substring(idx+5);
      w.write(line);
      w.write('\n');
      w.flush();
    }
  }
  r.close();
  w.close();
  }
View Full Code Here

  }

  protected BufferedWriter prepareWriter() throws XException
  {
    prepareWriteFile();
    BufferedWriter buffOut;
    try
    {
      buffOut = new BufferedWriter(
          new OutputStreamWriter(new FileOutputStream(mConfiguration
              .getFileNames()[0], true), mConfiguration
              .getEncoding()));
    }
    catch (Exception e)
View Full Code Here

    senderExecuted = true;

    if (callData == null)
      callData = "";

    BufferedWriter buffOut = null;

    // The file name to write to finnally.
    // Only several ones for broadcasting.
    // Otherwise only the first array element is filled.
    String[] fileNames = mConfiguration.getFileNames();

    for (int fileNo = 0; fileNo < fileNames.length; fileNo++)
    { // Loop over destination files.
      checkFilePermissions(fileNames[fileNo]);

      buffOut = prepareWriter(fileNames[fileNo], fileNo);

      // write callData into the file.
      // Characters written to it are translated into bytes
      // according to a specified character encoding.
      try
      {
        buffOut.write(callData);
        // Writing an end of file sign on Unix systems
        if (Constants.LINE_SEPERATOR.equals("\n")
            && (callData.length() == 0 || callData.charAt(callData
                .length() - 1) != '\n'))
          buffOut.newLine();
        buffOut.close();
      }
      catch (IOException e)
      {
        throw new XException(Constants.LOCATION_EXTERN,
            Constants.LAYER_TECHNICAL,
View Full Code Here

  protected BufferedWriter prepareWriter(String fileName, int fileNo)
      throws XException
  {
    prepareWriteFile(fileName, fileNo);
    BufferedWriter buffOut;
    try
    {
      buffOut = new BufferedWriter(new OutputStreamWriter(
          new FileOutputStream(mTempFilename[fileNo], true),
          mConfiguration.getEncoding()));
    }
    catch (Exception e)
    {
View Full Code Here

              entry.section).append(";").append(entry.key)
          .append(";").append(entry.type).append(";").append(
              entry.optional).append(Constants.LINE_SEPERATOR);
    }

    BufferedWriter buffOut = null;
    try
    {
      buffOut = new BufferedWriter(new OutputStreamWriter(
          new FileOutputStream(filename)));
      buffOut.write(strBuffer.toString());
    }
    catch (Exception e)
    {
      Trace.error(e);
      System.exit(1);
    }
    finally
    {
      if (buffOut != null)
      {
        try
        {
          buffOut.close();
        }
        catch (IOException e1)
        {
          // do nothing
        }
View Full Code Here

TOP

Related Classes of java.io.BufferedWriter

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.