Package java.io

Examples of java.io.InputStream


     *
     * TODO: optimize to reuse the same targetstream/buffer for small patterns
     * @throws SQLException
     */
    static private boolean validateMatch(StreamProvider pattern, StreamProvider target, long position) throws IOException, SQLException {
      InputStream targetStream = target.getBinaryStream();
      InputStream patternStream = pattern.getBinaryStream();
      try {
        targetStream.skip(position -1);     
        int value = 0;
        while ((value = patternStream.read()) != -1) {
          if (value != targetStream.read()) {
            return false;
          }
        }
      } finally {
        targetStream.close();
        patternStream.close();
      }
      return true;
    }
View Full Code Here


            }
        }
    }

    private void testFile(String inFile) throws Exception {
        InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
        in = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
        StringBuilder buff = new StringBuilder();
        while (true) {
            String sql = readLine();
            if (sql == null) {
View Full Code Here

    private static final String LINE_SEPARATOR = "\n"; //$NON-NLS-1$

  private Properties props = new Properties();

    private ApplicationInfo() {
    InputStream is = this.getClass().getResourceAsStream("application.properties"); //$NON-NLS-1$
    try {
      try {
        props.load(is);
      } finally {
        is.close();
      }
    } catch (IOException e) {
      throw new TeiidRuntimeException(e);
    }
    }
View Full Code Here

                while(readmes.hasMoreElements()) {
                    ++cnt;
                    URL url = (URL) readmes.nextElement();
                    sb.append("Patch " + url.getFile() + ":"); //$NON-NLS-1$ //$NON-NLS-2$
                    sb.append( LINE_SEPARATOR );
                    InputStream is = url.openStream();
                    byte[] data = ObjectConverterUtil.convertToByteArray(is);
                    sb.append(new String(data));
                    sb.append("-------------------------------------");//$NON-NLS-1$
                    sb.append( LINE_SEPARATOR );
                    is.close();

                }
            }
            if (cnt == 0) {
                sb.append("no Patch Readme Entries found"); //$NON-NLS-1$               
View Full Code Here

   /**
    *  Write a byte array to a file.
    */
    public static void write(byte[] data, String fileName) throws IOException {
        ByteArrayInputStream bais = null;
        InputStream is = null;
        try {
            bais = new ByteArrayInputStream(data);
            is = new BufferedInputStream(bais);
   
            write(is, fileName)
        } finally {
            if (is != null) {
                is.close();
            }
            if (bais != null) {
                bais.close();
            }
        }
View Full Code Here

  /**
   *  Write a byte array to a file.
   */
   public static void write(byte[] data, File file) throws IOException {
         ByteArrayInputStream bais = null;
         InputStream is = null;
         try {
         bais = new ByteArrayInputStream(data);
         is = new BufferedInputStream(bais);
   
         write(is, file)
         } finally {
             if (is != null) {
                 is.close();
             }
             if (bais != null) {
                 bais.close();
             }
         }
View Full Code Here

                    targetUri = URI.create(uri);
                } else {
                    targetUri = baseuri.resolve(uri);
                }
                URL targetUrl = targetUri.toURL();
                InputStream is = targetUrl.openStream();
                String rules = IOUtils.toString(is);
                col = new RuleBasedCollator(rules);
            } catch (Exception e) {
                return null;
            }
View Full Code Here

            if (dataSoc == null) {
                throw new IOException("Cannot open data connection.");
            }

            // create input stream
            InputStream is = dataSoc.getInputStream();
            if (factory.isZipMode()) {
                is = new InflaterInputStream(is);
            }
            return is;
        } catch (IOException ex) {
View Full Code Here

        int maxRate = 0;
        if (transferRateRequest != null) {
            maxRate = transferRateRequest.getMaxUploadRate();
        }

        InputStream is = getDataInputStream();
        try {
            return transfer(session, false, is, out, maxRate);
        } finally {
            IoUtils.close(is);
        }
View Full Code Here

  public InputStream
  getInputStream()
 
    throws IOException
  {
    InputStream  is = socket.getInputStream();
   
    String  line = "";
   
    byte[]  buffer = new byte[1];

    byte[]  line_bytes    = new byte[2048];
    int    line_bytes_pos   = 0;
   
    while(true){
   
      int  len = is.read( buffer );
     
      if ( len == -1 ){
       
        break;
      }
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.