Package java.io

Examples of java.io.BufferedWriter


    // Input piped to the called process
    List internalCommands = getProcessInputs();
    if (internalCommands != null && internalCommands.size() > 0)
    {
      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
          mProcess.getOutputStream()));
      try
      {
        for (int i = 0; i < internalCommands.size(); i++)
        {
          writer.write((String) internalCommands.get(i));
          writer.newLine();
        }
        writer.flush();
      }
      catch (IOException e)
      {
        List params = new Vector(1);
        params.add(cmdarray[0]);
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_TECHNICAL,
            Constants.PACKAGE_TECHNICAL_MISC, "7", e, params);
      }
      finally
      {
        try
        {
          writer.close();
        }
        catch (IOException e)
        {
          // do nothing
        }
View Full Code Here


    checkFilePermissions();
  }

  public String execute(String function, String callData) throws XException
  {
    BufferedWriter buffOut = prepareWriter();

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

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

  public Object execute(String function, Object source) throws XException
  {
    senderExecuted = true;

    LineReader reader = null;
    BufferedWriter buffOut = null;
    try
    {
      reader = (LineReader) source;
      reader.prepareReading(mDestination);
      buffOut = prepareWriter(mConfiguration.getFileNames()[0], 0);

      String record = reader.readRecord();
      String lastRecord = "";

      if (record != null)
      {
        buffOut.write(record);
        lastRecord = record;
        record = reader.readRecord();
      } // while (record != null)
      while (record != null)
      {
        buffOut.write(Constants.LINE_SEPERATOR);
        buffOut.write(record);
        lastRecord = record;
        record = reader.readRecord();
      } // while (record != null)

      // Writing an end of file sign on Unix systems
      if (Constants.LINE_SEPERATOR.equals("\n")
          && (lastRecord.length() == 0 || lastRecord
              .charAt(lastRecord.length() - 1) != '\n'))
        buffOut.newLine();
    }
    catch (Exception e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_FILE, "0", e);
    }
    finally
    {
      try
      {
        if (reader != null)
        {
          reader.terminateReading();
        }
        if (buffOut != null)
        {
          buffOut.close();
        }
      }
      catch (Exception e)
      {
        /*
 
View Full Code Here

        // Write toc_jsynoptic.html
        try{
            File indexFile = new File(outputDirectory, TOC_FILE_NAME);
            FileWriter writeFile= new FileWriter(indexFile);
            BufferedWriter writeBuf = new BufferedWriter(writeFile);   
            HTMLWriter writer = new HTMLWriter(writeBuf);
            writer.writeHtmlBegin();
            writer.writeBodyBegin();
           
            writer.writeHeadBegin();
            writer.writeTitle("JSynoptic Help");
            writer.writeHeadEnd();
           
            writer.writeH1("JSynoptic Help", null);

            // write the help index of contents
            createIndexOfContentsHTMLFiles(helpContents, writer);

            writer.writeBodyEnd();
            writer.writeHtmlEnd();
            writeBuf.close();
            writeFile.close();
            _logger.fine("File "+ TOC_FILE_NAME  + " successfully created at " + outputDirectory);

        } catch (IOException  e){
            _logger.severe("Cannot write index.html content. Reason is \n" + e.getMessage());
        }
       
       
        // Write jsynoptic.html
        try{
            File entryxFile = new File(outputDirectory, ENTRY_FILE_NAME);
            FileWriter writeFile= new FileWriter(entryxFile);
            BufferedWriter writeBuf = new BufferedWriter(writeFile);   
            HTMLWriter writer = new HTMLWriter(writeBuf);
            writer.writeHtmlBegin();

            writer.writeHeadBegin();
            writer.writeTitle("JSynoptic Help");
            writer.writeHeadEnd();
           
            writer.writeFrameSetBegin("33%,*");
            writer.writeFrame(TOC_FRAME_NAME, TOC_FILE_NAME);
            writer.writeFrame(CONTENT_FRAME_NAME, CONTENT_FIRST_PAGE_NAME);
           
            writer.writeNoframesBegin();
            writer.writeBodyBegin();
            writer.writeP("You must use a FRAME available browser");
            writer.writeBodyEnd();
            writer.writeNoframesEnd();
           
           
            writer.writeFrameSetEnd();

            writer.writeHtmlEnd();
            writeBuf.close();
            writeFile.close();
            _logger.fine("File "+ ENTRY_FILE_NAME  + " successfully created at " + outputDirectory);

        } catch (IOException  e){
            _logger.severe("Cannot write index.html content. Reason is \n" + e.getMessage());
View Full Code Here

   
    ImageIO.write(bi,resources.getString("imageFileExtension"),_imageFile);
    _htmlFile = new File(resources.getString("htmlFileName")).getCanonicalFile();

    FileWriter writeFile= new FileWriter(_htmlFile);
    BufferedWriter writeBuf = new BufferedWriter(writeFile)
    HTMLWriter writer = new HTMLWriter(writeBuf);
    writer.writeHtmlBegin();
    try{
      writer.writeTargetName("IMAGETARGET");
      writer.writeH1(sheetInformationTitle, null);

      // make links with descrition
      String[][] targets = new String[sheet.size()][5];

      for(int i=0;i<sheet.size();i++){
        Object o = sheet.get(i);
        if (o instanceof AbstractShape) {
          AbstractShape shape = (AbstractShape)o;

          // left-x, top-y, right-x, bottom-y
          targets[i][0] = new Integer(shape.getBounds().x).toString();
          targets[i][1] = new Integer(shape.getBounds().y).toString();
          targets[i][2] = new Integer(shape.getBounds().x + CIRCLE_SIZE+4).toString();
          targets[i][3] = new Integer(shape.getBounds().y + CIRCLE_SIZE+4).toString();

          // target name
          targets[i][4] = getShapeId(shape, i);

        }
      }
      // Write image with links
      writer.writeImage(_imageFile.getName(),resources.getString("imageFileTitle"), "IMAGEMAP", targets);
    }catch (IOException e){
      e.printStackTrace();
    }

    // Create sheet information
    for(int i=0;i<sheet.size();i++){
      Object o = sheet.get(i);
      if (o instanceof AbstractShape) {
        AbstractShape shape = (AbstractShape)o;

        // Shape name
        writer.writeTargetName(getShapeId(shape,i));
        writer.writeH2(getShapeId(shape, i),null);

        // Shape properties
        String[] propertiesNames = shape.getPropertyNames();
        ArrayList contents = new ArrayList();
       
        if (propertiesNames!=null){
          for(int j=0;j<propertiesNames.length;j++){
            String[] property = new String[2];
            property[0] = propertiesNames[j];

            Object obj = shape.getPropertyValue(propertiesNames[j]);
            if (obj!=null){
              if (obj instanceof NamedProperties){
                String[] objPropertiesNames = ((NamedProperties)obj).getPropertyNames();
                String objToString="";
                for(int k=0;k<objPropertiesNames.length;k++){
                  objToString+=objPropertiesNames[k] + " = " + ((NamedProperties)obj).getPropertyValue(objPropertiesNames[k]) + "\n";
                }
                property[1] = objToString;
             
              }else if (obj instanceof DataSource){
                property[1] = DataInfo.getAll(obj);
              }else{
                property[1] = obj.toString();
              }
              contents.add(property)
            }
          }
        }
        writer.writeTab(propertyTabTitles, contents);
        writer.writeP(resources.getString("goBackToImage"), "IMAGETARGET");
        writer.writeSeparator();
      }
    }
    writer.writeHtmlEnd();
    writeBuf.close();
    writeFile.close();
   
   
    // set html chooser for saving
    if(JSynoptic.gui!=null){
View Full Code Here

            log.finer(ii + ": [" + msgs[ii].toXml() + "]");
         }
      }

      // create a convenience writer to the socket outputstream
      BufferedWriter bw = null;
      try {
         bw = new BufferedWriter(new OutputStreamWriter(socket
               .getOutputStream()));
      } catch (IOException e) {
         log.throwing(this.getClass().getName(), "run", e);
      }

      try {
         // obtain the first! message, given in the message ...
         // ... and write it to the client
         if (msgs != null && msgs.length > 0) {
            bw.write(msgs[0].toXml());
         }

         bw.flush();
         bw.close();
      } catch (IOException e) {
         log.throwing(this.getClass().getName(), "run", e);
      }

      // close the clients socket connection
View Full Code Here

                } else {
                    if (verbose) {
                        System.out.println("Installing Text: " + entry.getName());
                    }

                    BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
                    BufferedReader reader = new BufferedReader(new InputStreamReader(jin));
                    for (String s = reader.readLine(); s != null; s = reader.readLine()) {
                        writer.write(s);
                        writer.newLine();
                    }
                    writer.close();
                }
                outFile.setLastModified(entry.getTime());
            }
           
        }
View Full Code Here

                    prop.put("status_url", url);
                    return prop;
                }
                try {
                    final File skinFile = new File(skinPath, url.substring(url.lastIndexOf('/'), url.length()));
                    final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(skinFile)));

                    while (it.hasNext()) {
                        bw.write(it.next() + "\n");
                    }
                   
                    bw.close();
                } catch (final IOException e) {
                    prop.put("status", "2");// error saving the skin
                    return prop;
                }
                if (post.containsKey("use_skin") && "on".equals(post.get("use_skin", ""))) {
View Full Code Here

                    prop.put("status_url", url);
                    return prop;
                }
                try {
                    final File langFile = new File(langPath, url.substring(url.lastIndexOf('/'), url.length()));
                    final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(langFile)));

                    while (it.hasNext()) {
                        bw.write(it.next() + "\n");
                    }
                    bw.close();
                } catch(final IOException e) {
                    prop.put("status", "2");//error saving the language file
                    return prop;
                }
                if (post.containsKey("use_lang") && "on".equals(post.get("use_lang"))) {
View Full Code Here

    try{

      // Now write to string and view as file.
      //System.out.println(iCal.getVCalendar());
     
      BufferedWriter out = new BufferedWriter(new FileWriter(args[1]));
          out.write(iCal.getVCalendar());
          out.close();
     
    }
    catch (Exception e)
    {
      e.printStackTrace();
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.