Package java.io

Examples of java.io.DataInputStream


     * Read in the video header from the stream.  This will tell
     * us how big to make the video component.
     */
    public boolean doPlayerRealize() {
        mic = new JMFMultiImageRenderer(this);
        DataInputStream in = null;

        try {
            //  Create an input stream
            in = new DataInputStream(
                new PullSourceInputStream(stream) );

            //  Read in the size of the video
            int w = in.readInt();
            int h = in.readInt();

            //  Read in the duration of the video (in nanos)
            duration = in.readLong();

            //  Set the preferred size
            mic.setImageSize( new Dimension(w,h) );
        }
       
        catch(EOFException e) {
            System.err.println("Unexpected EOF encountered in stream");

            postEvent(
                new ResourceUnavailableEvent(this,
                    "Unexpected EOF encountered while reading data stream") );

            return false;
        }

        catch(IOException e) {
            System.err.println("I/O Error reading data");

            postEvent(
                new ResourceUnavailableEvent(this,
                    "I/O error occurred while reading data stream") );

            return false;
        }
       
        finally {
            try { in.close(); } catch(Exception e) {}
        }

        //  Set the visualComponent
        setVisualComponent(mic);

View Full Code Here


    public boolean doPlayerPrefetch() {
        //  Has the data already been prefetched?
        if( ! prefetchNeeded ) return true;

        Vector frameVector = new Vector();
        DataInputStream in = null;

        try {
            //  Create an input stream
            in = new DataInputStream(
                new PullSourceInputStream(stream) );

            //  Load every image, first processing the image
            //  length and frame delay in the header
            try {
                while(true) {
                    //  Get frame length
                    long length = in.readLong();

                    //  Get frame delay
                    long nanos = in.readLong();

                    //  Get frame image
                    byte[] b = new byte[(int)length];
                    in.readFully(b,0,(int)length);
                    ImageIcon icon = new ImageIcon(b);

                    //  Update CachingControl
                    cache.addToProgress(16 + length);

                    //  Create MultiImageFrame object
                    MultiImageFrame m = new MultiImageFrame(icon, nanos);
                    frameVector.addElement(m);
                }
            }
           
            //  Read until EOF
            catch(EOFException e) {
                cache.setDone();
            }
        }
       
        catch(IOException e) {
            System.err.println("I/O Error reading data");

            postEvent(
                new ResourceUnavailableEvent(this,
                    "I/O error occurred while reading data stream") );

            return false;
        }
       
        finally {
            try { in.close(); } catch(Exception e) {}
        }

        //  Convert the vector to an array and set the frames
        MultiImageFrame[] frames = new MultiImageFrame[frameVector.size()];
        frameVector.copyInto(frames);
View Full Code Here

        try {
            String path= pathPrefix + "rx.dat";

      FileInputStream fin= new FileInputStream( path);
      BufferedInputStream bin= new BufferedInputStream( fin);
      DataInputStream din= new DataInputStream( bin);

      int n_targets= din.readInt();

      for( int i= 0; i < n_targets; i++) {
    String localPort= readString( din);
    String ip= readString( din);
    String port= readString( din);
View Full Code Here

        try {
            String path= pathPrefix + "xmit.dat";

      FileInputStream fin= new FileInputStream( path);
      BufferedInputStream bin= new BufferedInputStream( fin);
      DataInputStream din= new DataInputStream( bin);

            local_data_port= readString( din);

      int n_targets= din.readInt();

      for( int i= 0; i < n_targets; i++) {
    String ip= readString( din);
    String port= readString( din);
View Full Code Here

            System.exit(0);
        }

        Vector frameVector = new Vector();

        DataInputStream in = null;

        try {
            in = new DataInputStream(
                new FileInputStream(
                    new File(args[0]) ) );

            try {
                //  Read in the width/height/duration
                in.readInt();
                in.readInt();
                in.readLong();

                //  Read in the frames
                while(true) {
                    //  Read in the length of the frame
                    long length = in.readLong();

                    //  Read in the delay for the frame
                    long nanos = in.readLong();

                    //  Read in the frame image
                    byte[] b = new byte[(int)length];
                    in.readFully(b,0,(int)length);
                    ImageIcon icon = new ImageIcon(b);

                    //  Create a MultiImageFrame object and add to vector
                    MultiImageFrame m = new MultiImageFrame(icon, nanos);
                    frameVector.addElement(m);
                }
            } catch(EOFException e) {}
        }
       
        catch(IOException e) {
            System.err.println("Could not read in data");
            e.printStackTrace();
            System.exit(1);
        }
       
        finally {
            try { in.close(); } catch(IOException e) {}
        }

        //  Copy frames into array
        MultiImageFrame[] frames = new MultiImageFrame[frameVector.size()];
        frameVector.copyInto(frames);
View Full Code Here

                socket.getOutputStream(), true);

        is = socket.getInputStream();

        input =
            new DataInputStream(is);

        verifySuccessful();
        command(GROUP_CMD + " " + newsgroup);
    }
View Full Code Here

   private ClusterRequest readRequest(byte[] bytes) throws Exception
   {
      ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

      DataInputStream dais = new DataInputStream(bais);

      ClusterRequest request = ClusterRequest.createFromStream(dais);

      dais.close();

      return request;
   }
View Full Code Here

                 
         byte[] bytes = bos.toByteArray();
        
         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
                 
         DataInputStream dis = new DataInputStream(bis);
                
         int theId = dis.readInt();
        
         assertEquals(id, theId);
      }
View Full Code Here

                 
         byte[] bytes = bos.toByteArray();
        
         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
                 
         DataInputStream dis = new DataInputStream(bis);
                
         int theId = dis.readInt();
        
         assertEquals(PacketSupport.SERIALIZED, theId);
      }
View Full Code Here

    // Due to applet security, can only be invoked by run() thread
    private String readRawFile() {
        String rawData = "";
        try {
            byte[] buffer = new byte[512];
            DataInputStream in = new DataInputStream(new URL(file).openStream());
            //String inputLine;
            while (true) {
                int len = in.read(buffer);
                if (len == -1) {
                    break;
                }
                rawData += new String(buffer, 0, len, charset.name());
            }
            in.close();
        } catch (Exception e) {
            LogIt.log(Level.WARNING, "Error reading/parsing specified RAW file", e);
        }
        return rawData;
    }
View Full Code Here

TOP

Related Classes of java.io.DataInputStream

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.