Package java.io

Examples of java.io.InputStream


                                        FtpReply.REPLY_504_COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER,
                                        "MD5.invalid", fileName));
                return;
            }

            InputStream is = null;
            try {
                is = file.createInputStream(0);
                String md5Hash = md5(is);

                if (i > 0) {
View Full Code Here


            session.write(LocalizedFtpReply.translate(session, request, context,
                    FtpReply.REPLY_150_FILE_STATUS_OKAY, "RETR", null));

            // send file data to client
            boolean failure = false;
            InputStream is = null;

            DataConnection dataConnection;
            try {
                dataConnection = session.getDataConnection().openConnection();
            } catch (Exception e) {
                LOG.debug("Exception getting the output data stream", e);
                session.write(LocalizedDataTransferFtpReply.translate(session, request, context,
                        FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "RETR",
                        null, file));
                return;
            }

            long transSz = 0L;
            try {

                // open streams
                is = openInputStream(session, file, skipLen);

                // transfer data
                transSz = dataConnection.transferToClient(session.getFtpletSession(), is);
                // attempt to close the input stream so that errors in
                // closing it will return an error to the client (FTPSERVER-119)
                if(is != null) {
                    is.close();
                }

                LOG.info("File downloaded {}", fileName);

                // notify the statistics component
View Full Code Here

    /**
     * Skip length and open input stream.
     */
    public InputStream openInputStream(FtpIoSession session, FtpFile file,
            long skipLen) throws IOException {
        InputStream in;
        if (session.getDataType() == DataType.ASCII) {
            int c;
            long offset = 0L;
            in = new BufferedInputStream(file.createInputStream(0L));
            while (offset++ < skipLen) {
                if ((c = in.read()) == -1) {
                    throw new IOException("Cannot skip");
                }
                if (c == '\n') {
                    offset++;
                }
View Full Code Here

        String decoded = URLDecoder.decode(absolutePath);
        return new File(decoded);
    }

    public static byte[] getClassAsBytes(@Nonnull Class<?> clazz) throws IOException {
        InputStream is = getClassAsStream(clazz);
        return IOUtils.getBytes(is);
    }
View Full Code Here

    private void fillBuffer() throws IOException {
        final byte[] buffer = _buffer;
        if(buffer != null && _pos < buffer.length) {
            return;
        }
        final InputStream in = _in;
        int len = readInt(in);
        assert (len <= LZFOutputStream.DEFAULT_BUF_SIZE) : len;
        if(len < 0) { // not compressed
            len = -len;
            byte[] dest = ensureBuffer(buffer, len);
View Full Code Here

    }

    private CachedQuery loadQuery(String path) throws CacheException, IOException, XQueryException {
        final URL url;
        final long lastModified;
        final InputStream is;
        try {
            url = getServletContext().getResource(path);
            assert (url != null);
            lastModified = url.openConnection().getLastModified();
            is = url.openStream();
View Full Code Here

            throw new UnsupportedOperationException("WSDL style module is not supported yet.");
        }
        if(_resolver != null) {
            location = _resolver.resolveLocation(location);
        }
        InputStream is = openResource(location);
        XQueryModule module = obtainModule(is, _statEnv);
        // TODO should confirm namespace between library-module and target-namespace?
        final String modns = module.getNamespace();
        if(modns == null || modns.equals(targetNamespace) == false) {
            throw new StaticError("XQST0059", "target namespace '" + targetNamespace
View Full Code Here

            targetURL = targetURI.toURL();
        } catch (Exception e) {
            throw new StaticError("err:XQST0046", "targetNamespace is not a valid URL: "
                    + targetNamespace, e);
        }
        final InputStream is;
        try {
            is = targetURL.openStream();
        } catch (IOException e) {
            throw new StaticError("err:XQST0059", "Opening stream failed: " + targetURL, e);
        }
View Full Code Here

        return;
      }
    } else {
      helpFile = MessageText.getString("window.welcome.file");

      InputStream stream;
      stream = getClass().getResourceAsStream(helpFile);
      if (stream == null) {
        String helpFullPath = "/org/gudy/azureus2/internat/whatsnew/" + helpFile;
        stream = getClass().getResourceAsStream(helpFullPath);
      }
      if (stream == null) {
        stream = getClass().getResourceAsStream("/ChangeLog.txt");
      }
      if (stream == null) {
        sWhatsNew = "Welcome Window: Error loading resource: " + helpFile;
      } else {
        try {
          sWhatsNew = FileUtil.readInputStreamAsString(stream, 65535, "utf8");
          stream.close();
        } catch (IOException e) {
          Debug.out(e);
        }
      }
      setWhatsNew();
      return;
    }
   
    final String url = helpFile;
   
    new AEThread2("getWhatsNew", true) {

      public void run() {

        String s;
        ResourceDownloaderFactory rdf = ResourceDownloaderFactoryImpl.getSingleton();
        try {
          ResourceDownloader rd = rdf.create(new URL(url));
          InputStream is = rd.download();
          int length = is.available();
          byte data[] = new byte[length];
          is.read(data);
          is.close();
          s = new String(data);
        } catch (ResourceDownloaderException rde) {
          // We don't need a stack trace - it's arguable that we even need any
          // errors at all - the below line is better, but suppressed output might
          // be better.
View Full Code Here

     * @throws CryptoException
     * @throws IOException
     */
    public static SymmetricCryptor getSymmectricCryptor(URL keyResource) throws CryptoException, IOException {
    ArgCheck.isNotNull(keyResource);
    InputStream stream = keyResource.openStream();
    try {
        KeyStore store = KeyStore.getInstance("JCEKS"); //$NON-NLS-1$
        store.load(stream, DEFAULT_STORE_PASSWORD.toCharArray());
        Key key = store.getKey(DEFAULT_ALIAS, DEFAULT_STORE_PASSWORD.toCharArray());
        return new SymmetricCryptor(key);
        } catch (GeneralSecurityException e) {
            throw new CryptoException(e);
    } finally {
      stream.close();
    }
    }
View Full Code Here

TOP

Related Classes of java.io.InputStream

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.