tags:

views:

13

answers:

1

hello guys,

i am reading the bytes from binary file and now i have to get the index position of the stream and i am using CountingInputStream class and method getByteCount but this method returning me 0.

Here is my Code.

public void readIndex(InputStream iStream)
  {
   SwappedDataInputStream input;
   input = new SwappedDataInputStream(iStream);
   int locKey;
   int x=0;
   int y=0;

   try{
   setINoOfTiles(input.readInt());
   CountingInputStream cis = new CountingInputStream(iStream);

   for(int i=0; i<iNoOfTiles; i++)
   {
    x  = input.readInt()/100;
    y =input.readInt()/100;
    MapTileHeader tTile = new MapTileHeader(x, y, mapType);
    locKey = input.readInt();
    HashMap<Integer, MapTileHeader> iTileListOffsets = new HashMap<Integer, MapTileHeader>();
    iTileListOffsets.put(locKey, tTile);       
   }

   String out = IOUtils.toString(cis);
   long count = cis.getByteCount(); 
   Log.i("count", "count =" + count);
   }catch(Exception e )
   {
    e.printStackTrace();
   }
  }

i,ll be very thankful to you. tahnks alot

A: 

Use input = new SwappedDataInputStream(cis); and rearrange declarations accordingly.

Tassos Bassoukos
thanks brother i have done it by using your hint.
sajjoo