Package java.io

Examples of java.io.DataInputStream


    Socket socket = null;

    @Override
    public void run() {
      try {
        DataInputStream dis = new DataInputStream(socket.getInputStream());
        DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
       
        while(true) {
          int num = dis.readInt();
         
          dos.writeInt(num + 1);
        }
       
       
View Full Code Here


 
  public void longConnection() {
    Random rand = new Random();
    try {
      socket = new Socket("127.0.0.1", 8899);
      dis = new DataInputStream(socket.getInputStream());
      dos = new DataOutputStream(socket.getOutputStream());
    } catch (UnknownHostException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (IOException e1) {
View Full Code Here

  public void shortConnection() {
    Random rand = new Random();
    while(isRuning) {
      try {
        socket = new Socket("127.0.0.1", 8899);
        dis = new DataInputStream(socket.getInputStream());
        dos = new DataOutputStream(socket.getOutputStream());
      } catch (UnknownHostException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      } catch (IOException e1) {
View Full Code Here

    }
    if (handler == null) {
      throw new IllegalArgumentException("listener can not be 'null'");
    }

    this.in = new DataInputStream(in);

    // Check magic number
    byte[] magicNumber = IOUtil.readBytes(in, MAGIC_NUMBER.length);
    if (!Arrays.equals(magicNumber, MAGIC_NUMBER)) {
      throw new QueryResultParseException("File does not contain a binary RDF table result");
View Full Code Here

      // read it
      if (bais == null || dis == null)
      {
         if (trace) {  log.trace("internalArray:" + this.getPayload()); }
         bais = new ByteArrayInputStream((byte[])this.getPayload());
         dis = new DataInputStream(bais);
      }
   }
View Full Code Here

   public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException
   {           
      if (trace) { log.trace("Reading"); }
     
      DataInputStream dis;
     
      if (in instanceof DataInputStream)
      {
         //For non HTTP transports - we should ALWAYS be passed a DataInputStream
         //We do this by specifying socket wrapper classes on the locator uri
         dis = (DataInputStream)in;        
        
         if (trace) { log.trace("Stream is already DataInputStream :)"); }
      }
      else
      {       
         // Further sanity check
         if (in instanceof ObjectInputStream)
         {
            throw new IllegalArgumentException("Invalid stream - are you sure you have " +
                                               "configured socket wrappers?");
         }
        
         // This would be the case for the HTTP transport for example. Wrap the stream
        
         //FIXME Ideally remoting would let us wrap this before invoking the marshaller
         //     but this does not appear to be possible
         dis = new DataInputStream(in);
        
         if (trace) { log.trace("Stream is NOT DataInputStream - must be using HTTP transport"); }
      }
     
      int id = dis.readInt();
     
      PacketSupport packet = PacketSupport.createPacket(id);
     
      if (trace) { log.trace("Created packet " + packet); }
     
View Full Code Here

    base = aUrl;

    default_override = catalogManager.getPreferPublic();
    catalogManager.debug.message(4, "Parse catalog: " + aUrl.toString());

    DataInputStream inStream = null;
    boolean parsed = false;

    for (int count = 0; !parsed && count < readerArr.size(); count++) {
      CatalogReader reader = (CatalogReader) readerArr.get(count);

      try {
        inStream = new DataInputStream(aUrl.openStream());
      } catch (FileNotFoundException fnfe) {
        // No catalog; give up!
        break;
      }

      try {
        reader.readCatalog(this, inStream);
        parsed=true;
      } catch (CatalogException ce) {
        if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
          // give up!
          break;
        } else {
          // try again!
        }
      }

      try {
        inStream.close();
      } catch (IOException e) {
        //nop
      }
    }
View Full Code Here

    catalogManager.debug.message(2, "Loading catalog", fileName);
    catalogManager.debug.message(4, "Default BASE", base.toString());

    fileName = base.toString();

    DataInputStream inStream = null;
    boolean parsed = false;
    boolean notFound = false;

    for (int count = 0; !parsed && count < readerArr.size(); count++) {
      CatalogReader reader = (CatalogReader) readerArr.get(count);

      try {
  notFound = false;
  inStream = new DataInputStream(base.openStream());
      } catch (FileNotFoundException fnfe) {
  // No catalog; give up!
  notFound = true;
  break;
      }

      try {
  reader.readCatalog(this, inStream);
  parsed = true;
      } catch (CatalogException ce) {
  if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
    // give up!
    break;
  } else {
    // try again!
  }
      }

      try {
  inStream.close();
      } catch (IOException e) {
  //nop
      }
    }
View Full Code Here

     
      byte[] bytes = bos.toByteArray();
     
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
     
      DataInputStream dis = new DataInputStream(bis);
     
      String s2 = su.safeReadUTF(dis);
     
      assertEquals(s, s2);  
   }
View Full Code Here

     
      byte[] bytes = bos.toByteArray();
     
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
     
      DataInputStream dis = new DataInputStream(bis);
     
      String s2 = su.safeReadUTF(dis);
     
      assertEquals(s, s2);
     
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.