try { java.net.InetAddress localMachine = java.net.InetAddress.getByName( tempTracker.host ); tempTracker.host = localMachine.getHostAddress(); } catch ( java.net.UnknownHostException uhe ) { System.out.println( "Could not resolve: " + tempTracker.host + ": " + uhe ); }
  public void FromXML( DataInputStream inputStream )  {    DOMParser parser = new DOMParser();    try    {      parser.setFeature( "http://xml.org/sax/features/validation", false ); // don't      // validate    }    catch ( Exception e )    {      System.out.println( "Error: " + e );      System.exit( 0 );    }    try    {      parser.parse( new org.xml.sax.InputSource( inputStream ) );      Document floodDataDoc = parser.getDocument();      // get all our files and fill out our 'files' array      NodeList fileinfoList = floodDataDoc.getElementsByTagName( "FileInfo" );      // should only be one fileinfo tag      if ( fileinfoList.getLength() == 1 )      {        Element fileinfo = (Element) fileinfoList.item( 0 );        NodeList fileList = fileinfo.getElementsByTagName( "File" );        if ( fileList.getLength() > 0 )        {          files.setSize( fileList.getLength() );          for ( int fileIndex = 0; fileIndex < fileList.getLength(); fileIndex++ )          {            Element file = (Element) fileList.item( fileIndex );            TargetFile targetFile = new TargetFile();            targetFile.size = Long.parseLong( file.getAttribute( "size" ) );            targetFile.name = file.getAttribute( "name" );            NodeList chunkList = file.getElementsByTagName( "Chunk" );            if ( chunkList.getLength() > 0 )            {              targetFile.chunks.setSize( chunkList.getLength() );              for ( int chunkIndex = 0; chunkIndex < chunkList.getLength(); chunkIndex++ )              {                Element chunk = (Element) chunkList.item( chunkIndex );                Chunk tempChunk = new Chunk();                tempChunk.index = Integer.parseInt( chunk.getAttribute( "index" ) );                tempChunk.weight = Integer.parseInt( chunk.getAttribute( "weight" ) );                tempChunk.size = Integer.parseInt( chunk.getAttribute( "size" ) );                tempChunk.hash = chunk.getAttribute( "hash" );                targetFile.chunks.set( tempChunk.index, tempChunk );              }            }            files.set( fileIndex, targetFile );          }        }      }      // get all our trackers      NodeList trackersList = floodDataDoc.getElementsByTagName( "Tracker" );      if ( trackersList.getLength() > 0 )      {        trackers.setSize( trackersList.getLength() );        for ( int trackerIndex = 0; trackerIndex < trackersList.getLength(); trackerIndex++ )        {          Element tracker = (Element) trackersList.item( trackerIndex );          TrackerInfo tempTracker = new TrackerInfo();          tempTracker.host = tracker.getAttribute( "host" );          tempTracker.port = Integer.parseInt( tracker.getAttribute( "port" ) );          String idstring = tempTracker.host + tempTracker.port;          tempTracker.id = Encoder.SHA1Base64Encode( idstring );                    trackers.set( trackerIndex, tempTracker );        }      }      else      {        System.out.println( "No trackers in flood file?" );      }      //compute our content hash      ComputeContentHash();    }    catch ( Exception e )    {      System.out.println( "Error: " + e );    }  }