Package java.io

Examples of java.io.BufferedInputStream


     */
    public final byte[] getBytes() throws HttpConnectionException {
        try {
            ByteArrayOutputStream bais = new ByteArrayOutputStream();
            InputStream is = uc.getInputStream();
            BufferedInputStream bis  = new BufferedInputStream(is);
            while (true) {
                int i = bis.read();
                if (i == -1) break;
                bais.write(i);
            }
         
            bis.close();
            is.close();
           
            byte[] b = bais.toByteArray();
            bais.close();
   
View Full Code Here


      throws EvalError, IOException
  {
    final InputStream in = ObjectUtilities.getResourceRelativeAsStream
        ("BSHExpressionHeader.txt", BSHExpression.class); //$NON-NLS-1$
    // read the header, creates a skeleton
    final Reader r = new InputStreamReader(new BufferedInputStream(in));
    try
    {
      interpreter.eval(r);
    }
    finally
View Full Code Here

    /**
     * Initialize the transfer object. This method will try to open an input and
     * output stream.
     */
    public void init() throws IOException {
        in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), Transfer.BUFFER_SIZE));
        out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), Transfer.BUFFER_SIZE));
    }
View Full Code Here

    try {
      // due to an issue with AudioSystem.getAudioInputStream
      // and mixing unsigned and signed code
      // we will use the reader directly
      WaveFileReader wfr = new WaveFileReader();
      return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
    } catch (Exception e) {
      org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
      return null;
    }   
  }
View Full Code Here

   */
  public static WaveData create(byte[] buffer) {
    try {
      return create(
        AudioSystem.getAudioInputStream(
          new BufferedInputStream(new ByteArrayInputStream(buffer))));
    } catch (Exception e) {
      org.lwjgl.LWJGLUtil.log("Unable to create from byte array, " + e.getMessage());
      return null;
    }
  }
View Full Code Here

           
            File source_file = source.getFile();
           
            if ( source_file.exists()){
             
              job.setStream( new BufferedInputStream( new FileInputStream( source_file )));
             
            }else{
             
              throw( new TranscodeException( "No UPnPAV URL and file doesn't exist" ));
            }
          }else{
           
            URL source_url = new URL( url_str );
         
            job.setStream( source_url.openConnection().getInputStream());
          }
        }else{
         
          if ( device.getAlwaysCacheFiles()){
           
            PluginInterface av_pi = PluginInitializer.getDefaultInterface().getPluginManager().getPluginInterfaceByID( "azupnpav" );
           
            if ( av_pi == null ){
           
              throw( new TranscodeException( "Media Server plugin not found" ));
            }
           
            IPCInterface av_ipc = av_pi.getIPC();
           
            String url_str = (String)av_ipc.invoke( "getContentURL", new Object[]{ source });
           
            InputStream  is;
           
            long    length;
           
            if ( url_str == null || url_str.length() == 0 ){
             
                // see if we can use the file directly
             
              File source_file = source.getFile();
             
              if ( source_file.exists()){
               
                is = new BufferedInputStream( new FileInputStream( source_file ));
               
                length = source_file.length();
               
              }else{
               
View Full Code Here

     
      connection.setConnectTimeout( 30*1000 );
     
      InputStream is = connection.getInputStream();
     
      Map<String,Object> response = (Map<String,Object>)BDecoder.decode( new BufferedInputStream( is ));
     
      synchronized( this ){
       
        Long  min_retry = (Long)response.get( "min_secs" );
       
View Full Code Here

            connection.setConnectTimeout( 10*1000 );
           
            try{
              InputStream is = connection.getInputStream();
             
              Map<String,Object> response = (Map<String,Object>)BDecoder.decode( new BufferedInputStream( is ));
             
              response = BDecoder.decodeStrings( response );
             
              Long code = (Long)response.get( "code" );
             
View Full Code Here

  private SSLContext sslContext;

  public char monitor(Host host) {
    HttpHost httpHost = (HttpHost) host;
    HttpURLConnection http = null;
    BufferedInputStream bis = null;
    try {
      String urlString = null;

      if (httpHost.isSecure()) {
        urlString = "https://";
      } else {
        urlString = "http://";
      }
      urlString = urlString + httpHost.getInetAddress().getHostAddress()
          + ":" + httpHost.getInetSocketAddress().getPort() + httpHost.getUri();

      URL url = new URL(urlString);
      http = (HttpURLConnection) url.openConnection();
      if (httpHost.isSecure()) {
        HttpsURLConnection https = (HttpsURLConnection) http;

        makeSSLSocketFactory();

        https.setSSLSocketFactory(sslSocketFactory);
        https.setHostnameVerifier(vf);
      }
      http.setRequestMethod("GET");
      http.setDoOutput(true);
      http.setReadTimeout(httpHost.getTimeout());

      http.connect();

      String httpResponseCode = "" + http.getResponseCode();
      if(httpResponseCode.equals(httpHost.getHttpStatusCode())==false) {
        logger.fine("StatusCode does not match.. got "+httpResponseCode+
            ", expected: "+httpHost.getHttpStatusCode());
        return Host.DOWN;
      }

      if (httpHost.getTextToExpect() != null) {
        InputStream is = http.getErrorStream();
        if(is==null) {
          is = http.getInputStream();
        }
        bis = new BufferedInputStream(is);
       
        String textGot = new String(BlockingClient.readInputStream(bis), "utf-8");
        if (textGot.indexOf(httpHost.getTextToExpect()) != -1) {
          return Host.ACTIVE;
        } else {
          logger.fine(httpHost + " Error: Text [" + httpHost.getTextToExpect()
              + "]Not found! Got: " + textGot);
          return Host.DOWN;
        }
      } else {
        return Host.ACTIVE;
      }
    } catch (IOException e) {
      logger.fine(httpHost + " IOError: " + e);
      return Host.DOWN;
    } catch (Exception e) {
      logger.warning(httpHost + " Error: " + e);
      return Host.ERROR;
    } finally {
      if(bis!=null) {
        try {
          bis.close();
        } catch (IOException ex) {
          Logger.getLogger(HttpMonitor.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      if (http != null) {
View Full Code Here

  /** Creates a new server thread.
   * @param socket a socket in listening mode that handles client connections.
   */
  public ServerThread( final Socket socket ) throws IOException {
    this.socket = socket;
    inputStream = new DataInputStream( new BufferedInputStream( socket.getInputStream() ) );
    outputStream = new DataOutputStream( new BufferedOutputStream( socket.getOutputStream() ) );
  }
View Full Code Here

TOP

Related Classes of java.io.BufferedInputStream

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.