Package java.io

Examples of java.io.Writer


  private FileStoreInputStreamFactory buildResult() throws TeiidProcessingException {
    try {
      FileStore fs = context.getBufferManager().createFileStore("textagg"); //$NON-NLS-1$
      FileStoreInputStreamFactory fisf = new FileStoreInputStreamFactory(fs, textLine.getEncoding()==null?Streamable.ENCODING:textLine.getEncoding());
      Writer w = fisf.getWriter();
      if (textLine.isIncludeHeader()) {
        w.write(TextLine.evaluate(textLine.getExpressions(), new TextLine.ValueExtractor<DerivedColumn>() {
          public Object getValue(DerivedColumn t) {
            if (t.getAlias() == null && t.getExpression() instanceof ElementSymbol) {
              return ((ElementSymbol)t.getExpression()).getShortName();
            }
            return t.getAlias();
          }
        }, textLine.getDelimiter(), textLine.getQuote()));
      }
      w.flush();
      return fisf;
    } catch (IOException e) {
      throw new TeiidProcessingException(e);
    }
  }
View Full Code Here


      try {
        if (this.result == null) {
          this.result = buildResult();
        }
        String in = (String)input;
        Writer w = result.getWriter();
        w.write(in);
      w.flush();
    } catch (IOException e) {
      throw new TeiidProcessingException(e);
    }
    }
View Full Code Here

    if (f1.exists()) {
      Mapping mapping = new Mapping();
      try {
  mapping.loadMapping(mappingfile);
  Writer writer = new FileWriter(filename);
  Marshaller marshaller = new Marshaller(writer);
  marshaller.setMapping(mapping);
  marshaller.marshal(this);
  writer.close();
 
  log.info("written to XML");
      } catch (Exception e) {
  log.error(e.getMessage());
  e.printStackTrace();
View Full Code Here

        } else if(result instanceof SAXResult) {
            ContentHandler handler = ((SAXResult) result).getHandler();
            writeItemToSAX(handler);
        } else if(result instanceof StreamResult) {
            StreamResult streamResult = (StreamResult) result;
            final Writer writer = streamResult.getWriter();
            if(writer == null) {
                OutputStream os = streamResult.getOutputStream();
                writeItem(os, new Properties());
            } else {
                writeItem(writer, new Properties());
View Full Code Here

      metaData.setDescription(description);
      metaData.setCacheable(cacheable);
      metaData.setCategory(category);
      XStream xstream = new XStream(new DomDriver());
      xstream.alias(TMLMetadataInfo.XSTREAM_ALIAS, TMLMetadataInfo.class);
      Writer writer = null;
      try {
        if (!_metadataFolder.exists()) {
          _metadataFolder.create(true, true, new NullProgressMonitor())
          _metadataFile = _metadataFolder.getFile(_tmlFile.getName().substring(0, _tmlFile.getName().length() - _tmlFile.getFileExtension().length()) + "metadata.xml");
        }

        writer = new OutputStreamWriter(new FileOutputStream(_metadataFile.getLocation().toFile()), _fileEncoding);
        xstream.toXML(metaData, writer);
       
      } catch (CoreException e) {
        IOException ioe = new IOException("Unable to save metadata file '" + _metadataFile.getLocation() + "'.");
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
      } finally {
        if (writer != null) {
          try {
            writer.close();
          } catch (IOException e) {
          }
          try {
            if(_metadataFile!=null){
              _metadataFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
View Full Code Here

     * )
     */
    public final void transferToClient(FtpSession session, final String str)
            throws IOException {
        OutputStream out = getDataOutputStream();
        Writer writer = null;
        try {
            writer = new OutputStreamWriter(out, "UTF-8");
            writer.write(str);

            // update session
            if (session instanceof DefaultFtpSession) {
                ((DefaultFtpSession) session).increaseWrittenDataBytes(str
                        .getBytes("UTF-8").length);
            }
        } finally {
            if (writer != null) {
                writer.flush();
            }
            IoUtils.close(writer);
        }

    }
View Full Code Here

     * whatever the encoding
     * @throws IOException on error
     */
    public static void exportToXML(HashMap names, OutputStream out, String encoding, boolean onlyASCII) throws IOException {
        String jenc = IanaEncodings.getJavaEncoding(encoding);
        Writer wrt = new BufferedWriter(new OutputStreamWriter(out, jenc));
        exportToXML(names, wrt, encoding, onlyASCII);
    }
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();
        } catch (IOException e) {
        }
      }
    }
   
View Full Code Here

      throws TeiidComponentException, TeiidProcessingException {       
      boolean success = false;
      final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$
      FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING);
      try
        Writer writer = fsisf.getWriter();
          translator.translate(writer);
          writer.close();
          success = true;
          return new SQLXMLImpl(fsisf);
      } catch(IOException e) {
          throw new TeiidComponentException(e);
      } catch(TransformerException e) {
View Full Code Here

            IOException, XQueryException {
        XQEngine engine = new XQEngineClient(remoteEndpoint);
        String query = IOUtils.toString(new FileInputStream(fileName));
        QueryRequest request = new QueryRequest(query, ReturnType.ASYNC_REMOTE_SEQUENCE);
        Sequence<Item> resultSeq = (Sequence<Item>) engine.execute(request);
        Writer writer = new FastBufferedWriter(new OutputStreamWriter(System.out), 4096);
        SAXWriter saxwr = new SAXWriter(writer, "UTF-8");
        Serializer ser = new SAXSerializer(saxwr, writer);
        ser.emit(resultSeq);
        writer.flush();
    }
View Full Code Here

TOP

Related Classes of java.io.Writer

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.