Package java.io

Examples of java.io.BufferedInputStream.mark()


    public synchronized void load(InputStream in) throws IOException {
        if (in == null) {
            throw new NullPointerException();
        }
        BufferedInputStream bis = new BufferedInputStream(in);
        bis.mark(Integer.MAX_VALUE);
        boolean isEbcdic = isEbcdic(bis);
        bis.reset();

        if(!isEbcdic){
            loadImpl(new InputStreamReader(bis, "ISO8859-1")); //$NON-NLS-1$
View Full Code Here


      // start with the header of BZ. So it works fine either we have
      // the header or not.
      BufferedInputStream bufferedIn = null;
      if (super.in != null) {
        bufferedIn = new BufferedInputStream(super.in);
        bufferedIn.mark(HEADER_LEN);
        byte[] headerBytes = new byte[HEADER_LEN];
        int actualRead = bufferedIn.read(headerBytes, 0, HEADER_LEN);
        if (actualRead != -1) {
          String header = new String(headerBytes);
          if (header.compareTo(HEADER) != 0) {
View Full Code Here

            byte[] reply = new byte[size];

            // figure out the stream size as we need to pass it in the header
            BufferedInputStream buffer = new BufferedInputStream(data, size);
            try {
                buffer.mark(Integer.MAX_VALUE);
                while ((read = buffer.read(reply)) != -1) {
                    count += read;
                }

                // send the header
View Full Code Here

    public void testMarkReset() throws IOException {
        File temp = File.createTempFile("test", null);
        TempFileInputStream.writeToFileAndClose(new ByteArrayInputStream(new byte[10]), temp);
        InputStream in = new BufferedInputStream(new TempFileInputStream(temp, false));
        in.mark(100);
        for (int i = 0; i < 10; i++) {
            assertEquals(0, in.read());
        }
        assertEquals(-1, in.read());
        in.reset();
View Full Code Here

    private HeaderParser() {
    }

    public static InputStream wireTapManifest( InputStream is, Manifest mf ) throws IOException {
        BufferedInputStream bis = new BufferedInputStream( is, 64 * 1024 );
        bis.mark( 64 * 1024 );
        JarInputStream jis = new JarInputStream( bis );
        mf.getMainAttributes().putAll( jis.getManifest().getMainAttributes() );
        mf.getEntries().putAll( jis.getManifest().getEntries() );
        bis.reset();
        return bis;
View Full Code Here

            InputStream in = httpRequest.getInputStream();
            if (in != null) {
                // use a buffered input stream to find out whether there actually
                // is a request body
                InputStream bin = new BufferedInputStream(in);
                bin.mark(1);
                boolean isEmpty = -1 == bin.read();
                bin.reset();
                if (!isEmpty) {
                    DocumentBuilder docBuilder = DomUtil.BUILDER_FACTORY.newDocumentBuilder();
                    requestDocument = docBuilder.parse(bin);
View Full Code Here

            OutputStream outStream, final UpdateOptions options)
            throws IOException, SAXException {
        final PrintWriter out = new PrintWriter(new OutputStreamWriter(outStream, "UTF-8"));
        final BufferedInputStream in = new BufferedInputStream(inStream);

        in.mark(MAX_HEADER_LENGTH); // assume the header is never larger than 10000 bytes.
        copyHeader(in, out);
        in.reset(); // reposition the stream at the beginning

        try {
            UpdaterHandler updaterHandler = new UpdaterHandler(inStreamCtx, out, options);
View Full Code Here

        BufferedInputStream is = new BufferedInputStream(getInputStream(path));

        String enc = "UTF-8";
        try
        {
            is.mark(MAX_BUFFER_SIZE);
            byte[] buf = new byte[MAX_BUFFER_SIZE];
            int size = is.read(buf, 0, MAX_BUFFER_SIZE);
            if (size > 0)
            {
                String key = "encoding=\"";
View Full Code Here

            InputStream in = httpRequest.getInputStream();
            if (in != null) {
                // use a buffered input stream to find out whether there actually
                // is a request body
                InputStream bin = new BufferedInputStream(in);
                bin.mark(1);
                boolean isEmpty = -1 == bin.read();
                bin.reset();
                if (!isEmpty) {
                    requestDocument = DomUtil.parseDocument(bin);
                }
View Full Code Here

        //int i = 0;
        StringBuffer sb = new StringBuffer( length < 0 ? 16 : length);
        BufferedInputStream bufferedIn = new BufferedInputStream(inStream);
        String charset = context.getHttpMethod().getResponseCharSet();

        bufferedIn.mark(4);

        // Check for BOM as InputStreamReader does not strip BOM in all cases.
        boolean hasBOM = false;
        int read = bufferedIn.read();
        if (read > 0)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.