Package java.io

Examples of java.io.InputStream


       
        FTPTransferType previousType = transferType;
        FTPTransferType currentTransferType = chooseTransferMode(remoteFile);

        try {
            InputStream srcStream = null;
            if (retryCount == 0 || append) {
                srcStream = new FileInputStream(localPath);
                remoteFile = putStream(srcStream, remoteFile, append);
            } else {
                for (int attempt = 1;; attempt++) {
View Full Code Here


        }
    }

    public void get(OutputStream destStream, String remoteFile)
            throws IOException, FTPException {
        InputStream str = null;
        try {
            str = client.downloadStream(remoteFile);
       
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = str.read(buf)) >= 0) {
                destStream.write(buf, 0, len);
            }
        }
        finally {
            str.close();
        }
    }
View Full Code Here

            if (args.length != 1) {
                throw new IllegalArgumentException("Image.getInfo() expects one argument");
            }

            Object arg = args[0];
            InputStream in = null;
            ImageInfo info = new ImageInfo();
            Object ret = null;
   
            try {
                if (arg instanceof Wrapper) {
                    arg = ((Wrapper) arg).unwrap();
                }
   
                if (arg instanceof InputStream) {
                    in = (InputStream) arg;
                } else if (arg instanceof byte[]) {
                    in = new ByteArrayInputStream((byte[]) arg);
                } else if (arg instanceof MimePart) {
                    in = new ByteArrayInputStream(((MimePart) arg).getContent());
                } else if (arg instanceof File) {
                    in = new FileInputStream((File) arg);
                } else if (arg instanceof FileObject) {
                    in = new FileInputStream(((FileObject)arg).getFile());
                } else if (arg instanceof String) {
                    String str = (String) arg;
                    // try to interpret argument as URL if it contains a colon,
                    // otherwise or if URL is malformed interpret as file name.
                    if (str.indexOf(":") > -1) {
                        try {
                            URL url = new URL(str);
                            in = url.openStream();
                        } catch (MalformedURLException mux) {
                            in = new FileInputStream(str);
                        }
                    } else {
                        in = new FileInputStream(str);
                    }
                }
   
                if (in == null) {
                    String msg = "Unrecognized argument in Image.getInfo(): ";
                    msg += arg == null ? "null" : arg.getClass().toString();
                    throw new IllegalArgumentException(msg);
                }
   
                info.setInput(in);
                if (info.check()) {
                    ret = Context.toObject(info, scope);
                }
   
            } catch (IOException e) {
                // do nothing, returns null later
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException ee) {
                    }
                }
            }
            return ret;
View Full Code Here

     * method.
     * @param locale locale which will be used to determine which message file from bundle will be used
     * @return true if the intialization was succesfull, false if there was any problem.
     */
    public static boolean initLocalizationSupport(String locale) {
        InputStream in = null;
        // need access to a class object - cannot use Object.class, because of MIDP1 bug
        Class clazz = Runtime.getRuntime().getClass();
        try {
            // try to find localized resource first (in format ${name}_locale.${suffix})
            if ((locale != null) && (locale.length() > 1)) {
View Full Code Here

     * @throws NoSuchAlgorithmException
     * @throws CertificateException
     * @throws UnrecoverableKeyException
     */
    private void initConfiguredKey() throws Exception {
        InputStream inputStream=null;
        // must not use default keystore type - as does not support secret keys
        KeyStore store=KeyStore.getInstance("JCEKS");

        SecretKey tempKey=null;
        try {
View Full Code Here

    super(syncInfoFile.getLocation().toFile());
    _designContainer =  syncInfoFile.getParent();
    _lastDirectAccessDefault = isDirectAccessDefault();
    if (getSchemaDefinitionFile() != null && getSchemaDefinitionFile().exists()) {
        // handle empty schema.xml
        InputStream schemaIn = null;
        try {
            schemaIn = getSchemaDefinitionFile().getContents();
            if (schemaIn.read() == -1) {
                // schema.xml is empty
                _schema = new WGSchemaDefinition();
            } else {
                try {
                        _schema = WGSchemaDefinition.read(getSchemaDefinitionFile().getContents());
                    }
                    catch (Exception e) {
                        IOException ioe = new IOException("Unable to read schema definition '" + getSchemaDefinitionFile().getLocation() + "'.");
                        ioe.setStackTrace(e.getStackTrace());
                        throw ioe;
                    }
            }
        } catch (CoreException e) {
            IOException ioe = new IOException("Unable to read schema definition '" + getSchemaDefinitionFile().getLocation() + "'.");
                ioe.setStackTrace(e.getStackTrace());
                throw ioe;
        } finally {
            if (schemaIn != null) {
                schemaIn.close();
            }
        }
    }
  }
View Full Code Here

      if (xml.substring(xml.length() - 3, xml.length()).equals("xml"))
      {
        returnDocument = builder.parse(new File(filePath + xml));
      } else
      {
        InputStream in = new BufferedInputStream(new StringBufferInputStream(xml));
        returnDocument = builder.parse(in);
      }
    } catch (IOException e)
    {
      logger.error("[getDocumentFromString] Exception thrown.", e);
View Full Code Here

            while (pnum.hasMoreElements()) {

                // parameter name is path and value is service definition file
                path = (String) pnum.nextElement();
                file = "/WEB-INF/" + servlet.getInitParameter(path);
                InputStream is = null;
                try {
                    is = serv.getResourceAsStream(file);
                    if (is == null) {
                        logger.error("Service definition not found for service " + path + " at " + file);
                        throw new UnavailableException("Service definition not found for service " + path + " at "
                            + file + ". Check configuration of servlet " + servlet.getServletName()
                            + " in WEB-INF/web.xml.");
                    }
                    ServiceDefinition sdef = (ServiceDefinition) ctx.unmarshalDocument(is, null);
                    if (!path.startsWith("/")) {
                        path = "/" + path;
                    }
                    map.put(path, sdef);

                } finally {
                    if (is != null) {
                        try {
                            is.close();
                        } catch (IOException ignore) {
                        }
                    }
                }
            }
View Full Code Here

        }

        /** {@inheritDoc} */
        public IXMLReader getReader() throws IOException {
            if (m_reader == null) {
                InputStream inputStream = m_request.getInputStream();
                if (m_interceptor != null) {
                    inputStream = m_interceptor.intercept(inputStream);
                }
                m_buffer.setInput(inputStream);
                m_reader = m_codec.getReader(m_buffer, m_request.getCharacterEncoding(), m_request.getRemoteAddr(),
View Full Code Here

        UserObject userobjectd = (UserObject) session.getAttribute("userobject");
        int userid = userobjectd.getIndividualID();

        FormFile ff = (FormFile) fileform.getFile();
        String fileName = ff.getFileName();
        InputStream im = ff.getInputStream();

        CvFileFacade cvfile = new CvFileFacade();
        CvFileVO flvo = new CvFileVO();
        flvo.setTitle(fileName); //file name
View Full Code Here

TOP

Related Classes of java.io.InputStream

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.