java.io.DataInputStream Java Examples

The following examples show how to use java.io.DataInputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NativeRuntime.java    From Social with Apache License 2.0 6 votes vote down vote up
/**
 * 执行本地用户命令
 * @date 2016-1-18 下午8:23:01
 * @param pacaageName
 * @param command
 * @param sb_out_Result
 * @return
 */
public boolean RunLocalUserCommand(String pacaageName, String command, StringBuffer sb_out_Result) {
    Process process = null;
    try {
        process = Runtime.getRuntime().exec("sh"); // 获得shell进程
        DataInputStream inputStream = new DataInputStream(process.getInputStream());
        DataOutputStream outputStream = new DataOutputStream(process.getOutputStream());
        outputStream.writeBytes("cd /data/data/" + pacaageName + "\n"); // 保证在command在自己的数据目录里执行,才有权限写文件到当前目录
        outputStream.writeBytes(command + " &\n"); // 让程序在后台运行,前台马上返回
        outputStream.writeBytes("exit\n");
        outputStream.flush();
        process.waitFor();
        byte[] buffer = new byte[inputStream.available()];
        inputStream.read(buffer);
        String s = new String(buffer);
        if (sb_out_Result != null)
            sb_out_Result.append("CMD Result:\n" + s);
    } catch (Exception e) {
        if (sb_out_Result != null)
            sb_out_Result.append("Exception:" + e.getMessage());
        return false;
    }
    return true;
}
 
Example #2
Source File: Server.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void saslReadAndProcess(DataInputStream dis) throws
WrappedRpcServerException, IOException, InterruptedException {
  final RpcSaslProto saslMessage =
      decodeProtobufFromStream(RpcSaslProto.newBuilder(), dis);
  switch (saslMessage.getState()) {
    case WRAP: {
      if (!saslContextEstablished || !useWrap) {
        throw new WrappedRpcServerException(
            RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
            new SaslException("Server is not wrapping data"));
      }
      // loops over decoded data and calls processOneRpc
      unwrapPacketAndProcessRpcs(saslMessage.getToken().toByteArray());
      break;
    }
    default:
      saslProcess(saslMessage);
  }
}
 
Example #3
Source File: CachedCrudAssist.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public T copyForWrite(T entity) {
    if (entity.isCachedAndShared() == false)
        return entity;

    T copy;
    try {
        byte[] bytes;
        try (ByteArrayOutputStream buf = new ByteArrayOutputStream();
                DataOutputStream dout = new DataOutputStream(buf)) {
            serializer.serialize(entity, dout);
            bytes = buf.toByteArray();
        }

        try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes))) {
            copy = serializer.deserialize(in);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    copy.setCachedAndShared(false);
    initEntityAfterReload(copy, entity.resourceName());
    return copy;
}
 
Example #4
Source File: TestTupleWritable.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Tests compatibility with pre-0.21 versions of TupleWritable
 */
public void testPreVersion21Compatibility() throws Exception {
  Writable[] manyWrits = makeRandomWritables(64);
  PreVersion21TupleWritable oldTuple = new PreVersion21TupleWritable(manyWrits);
  
  for (int i =0; i<manyWrits.length; i++) {
    if (i % 3 == 0) {
      oldTuple.setWritten(i);
    }
  }
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  oldTuple.write(new DataOutputStream(out));
  ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
  TupleWritable dTuple = new TupleWritable();
  dTuple.readFields(new DataInputStream(in));
  assertTrue("Tuple writable is unable to read pre-0.21 versions of TupleWritable", oldTuple.isCompatible(dTuple));
  assertEquals("All tuple data has not been read from the stream",-1,in.read());
}
 
Example #5
Source File: DTD.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private AttributeList readAttributeList(DataInputStream in, String[] names)
                throws IOException  {
        AttributeList result = null;
        for (int num = in.readByte(); num > 0; --num) {
            short nameId = in.readShort();
            int type = in.readByte();
            int modifier = in.readByte();
            short valueId = in.readShort();
            String value = (valueId == -1) ? null : names[valueId];
            Vector<String> values = null;
            short numValues = in.readShort();
            if (numValues > 0) {
                values = new Vector<String>(numValues);
                for (int i = 0; i < numValues; i++) {
                    values.addElement(names[in.readShort()]);
                }
            }
result = new AttributeList(names[nameId], type, modifier, value,
                                       values, result);
            // We reverse the order of the linked list by doing this, but
            // that order isn't important.
        }
        return result;
    }
 
Example #6
Source File: ColumnExpressionTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Test
public void testSerialization() throws Exception {
    int maxLen = 30;
    int scale = 5;
    PName colName = PNameFactory.newName("c1");
    PColumn column = new PColumnImpl(colName, PNameFactory.newName("f1"), PDecimal.INSTANCE, maxLen, scale,
            true, 20, SortOrder.getDefault(), 0, null, false, null, false, false, colName.getBytes(), HConstants.LATEST_TIMESTAMP);
    ColumnExpression colExp = new KeyValueColumnExpression(column);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dOut = new DataOutputStream(baos);
    colExp.write(dOut);
    dOut.flush();

    ColumnExpression colExp2 = new KeyValueColumnExpression();
    byte[] bytes = baos.toByteArray();
    DataInputStream dIn = new DataInputStream(new ByteArrayInputStream(bytes, 0, bytes.length));
    colExp2.readFields(dIn);
    assertEquals(maxLen, colExp2.getMaxLength().intValue());
    assertEquals(scale, colExp2.getScale().intValue());
    assertEquals(PDecimal.INSTANCE, colExp2.getDataType());
}
 
Example #7
Source File: SpongePlugin.java    From BungeeTabListPlus with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onServerAboutToStart(GameAboutToStartServerEvent event) {

    // register plugin message channel
    channel = game.getChannelRegistrar().createRawChannel(this, BridgeProtocolConstants.CHANNEL);
    channel.addListener(Platform.Type.SERVER, (data, connection, side) -> {
        if (connection instanceof PlayerConnection) {
            Player player = ((PlayerConnection) connection).getPlayer();
            DataInput input = new DataInputStream(new ChannelBufInputStream(data));
            try {
                bridge.onMessage(player, input);
            } catch (Throwable e) {
                rlExecutor.execute(() -> {
                    logger.error("Unexpected error", e);
                });
            }
        }
    });

    // init bridge
    initBridge();
}
 
Example #8
Source File: KeySetAnnouncement.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void readWire(final DataInputStream in) throws IOException, ClassNotFoundException {

   super.readWire(in);

   bucketOwnerAddress = SerializerUtils.readAddress(in);

   final int keySetSize = in.readInt();
   keySet = new IntObjectHashMap<HashSet<Binary>>(keySetSize);
   for (int i = 0; i < keySetSize; i++) {

      final int bucketNumber = in.readShort();
      final int keysSize = in.readInt();
      final HashSet<Binary> keys = new HashSet<Binary>(keysSize);
      for (int j = 0; j < keysSize; j++) {

         keys.add(SerializerUtils.readBinary(in));
      }
      keySet.put(bucketNumber, keys);
   }
}
 
Example #9
Source File: LineNumberTableAttribute.java    From whyline with MIT License 6 votes vote down vote up
private LineNumberTableEntry[] parseLines() {

		if(lines == null) {
			try {
				DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes));
				lineNumberTableLength = data.readUnsignedShort();
				lines = new LineNumberTableEntry[lineNumberTableLength];
				for(int i = 0; i < lineNumberTableLength; i++) {
					int startPC = data.readUnsignedShort();
					int line = data.readUnsignedShort();
					Instruction inst = code.getInstructionAtByteIndex(startPC);
					lines[i] = new LineNumberTableEntry(pool.getClassfile(), inst, line);			
				}
				bytes = null;
			} catch(IOException e) {
				e.printStackTrace();
			}

		}
		return lines;
		
	}
 
Example #10
Source File: AddressIndexBlock.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
private static byte[] input(byte[] ins, String name) throws IOException {
	int find = Character.toLowerCase(name.charAt(4));
	ByteArrayInputStream tmp = new ByteArrayInputStream(ins);
	DataInputStream in = new DataInputStream(tmp);
	for (;;) {
		in.readInt();
		int valueLength = in.readInt();
		byte keyBuffer = in.readByte();
		if (keyBuffer == find) {
			byte[] valueBuffer = new byte[valueLength];
			in.read(valueBuffer, 0, valueLength);
			return valueBuffer;
		} else {
			in.skipBytes(valueLength);
		}
	}
}
 
Example #11
Source File: Currency.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static List<OtherCurrencyEntry> readOtherCurrencies(DataInputStream dis,
        int count)
        throws IOException {

    List<OtherCurrencyEntry> list = new ArrayList<>(count);
    String currencyCode;
    int fraction;
    int numericCode;

    for (int i = 0; i < count; i++) {
        currencyCode = dis.readUTF();
        fraction = dis.readInt();
        numericCode = dis.readInt();
        OtherCurrencyEntry oc = new OtherCurrencyEntry(currencyCode,
                fraction,
                numericCode);
        list.add(oc);
    }
    return list;
}
 
Example #12
Source File: MetadataV3Serializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected OperatorState deserializeOperatorState(DataInputStream dis, @Nullable DeserializationContext context) throws IOException {
	final OperatorID jobVertexId = new OperatorID(dis.readLong(), dis.readLong());
	final int parallelism = dis.readInt();
	final int maxParallelism = dis.readInt();

	final OperatorState operatorState = new OperatorState(jobVertexId, parallelism, maxParallelism);

	// Coordinator state
	operatorState.setCoordinatorState(deserializeAndCheckByteStreamStateHandle(dis, context));

	// Sub task states
	final int numSubTaskStates = dis.readInt();

	for (int j = 0; j < numSubTaskStates; j++) {
		final int subtaskIndex = dis.readInt();
		final OperatorSubtaskState subtaskState = deserializeSubtaskState(dis, context);
		operatorState.putState(subtaskIndex, subtaskState);
	}

	return operatorState;
}
 
Example #13
Source File: CubeQueryDefinitionIOUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private static IDimensionDefinition loadDimensionDefinition( DataInputStream dis ) throws IOException
{
	if ( !IOUtil.readBool( dis ) )
	{
		return null;
	}
	String name = IOUtil.readString( dis );
	DimensionDefinition dd = new DimensionDefinition( name );
	int hierarchyCount = IOUtil.readInt( dis );
	for ( int i=0; i<hierarchyCount; i++)
	{
		String hierarchyName = IOUtil.readString( dis );
		IHierarchyDefinition hd = dd.createHierarchy( hierarchyName );
		int levelCount = IOUtil.readInt( dis );
		for ( int j=0; j<levelCount; j++)
		{
			String levelName = IOUtil.readString( dis );
			hd.createLevel( levelName );
		}
	}
	return dd;
}
 
Example #14
Source File: StatArchiveReader.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public StatArchiveFile(StatArchiveReader reader,
                       File archiveName,
                       boolean dump,
                       ValueFilter[] filters)
  throws IOException
{
  this.reader = reader;
  this.archiveName = archiveName;
  this.dump = dump;
  this.compressed = archiveName.getPath().endsWith(".gz");
  this.is = new FileInputStream(this.archiveName);
  if (this.compressed) {
    this.dataIn = new DataInputStream(new BufferedInputStream(new GZIPInputStream(this.is, BUFFER_SIZE), BUFFER_SIZE));
  } else {
    this.dataIn = new DataInputStream(new BufferedInputStream(this.is, BUFFER_SIZE));
  }
  this.updateOK = this.dataIn.markSupported();
  this.filters = createFilters(filters);
}
 
Example #15
Source File: WorkspaceProviderTests.java    From nd4j with Apache License 2.0 6 votes vote down vote up
@Test
public void testWorkspacesSerde1() throws Exception {
    int[] shape = new int[] {17, 57, 79};
    INDArray array = Nd4j.create(shape).assign(1.0);
    INDArray restored = null;

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    Nd4j.write(array, dos);

    try (MemoryWorkspace workspace = Nd4j.getWorkspaceManager().getAndActivateWorkspace(bigConfiguration, "WS_1")) {
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        DataInputStream dis = new DataInputStream(bis);
        restored = Nd4j.read(dis);

        assertEquals(array.length(), restored.length());
        assertEquals(1.0f, restored.meanNumber().floatValue(), 1.0f);

        // we want to ensure it's the same cached shapeInfo used here
        assertTrue(array.shapeInfoDataBuffer() == restored.shapeInfoDataBuffer());
    }
}
 
Example #16
Source File: Vocabulary.java    From joshua with Apache License 2.0 6 votes vote down vote up
/**
 * Reads a vocabulary from file. This deletes any additions to the vocabulary made prior to
 * reading the file.
 *
 * @param vocab_file path to a vocabulary file
 * @return Returns true if vocabulary was read without mismatches or collisions.
 * @throws IOException of the file cannot be found or read properly
 */
public static boolean read(final File vocab_file) throws IOException {
  DataInputStream vocab_stream =
      new DataInputStream(new BufferedInputStream(new FileInputStream(vocab_file)));
  int size = vocab_stream.readInt();
  LOG.info("Read {} entries from the vocabulary", size);
  clear();
  for (int i = 0; i < size; i++) {
    int id = vocab_stream.readInt();
    String token = vocab_stream.readUTF();
    if (id != Math.abs(id(token))) {
      vocab_stream.close();
      return false;
    }
  }
  vocab_stream.close();
  return (size + 1 == idToString.size());
}
 
Example #17
Source File: ClassfileConstantPool.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
ClassfileConstantPool(DataInputStream stream, ClassfileBytecodeProvider context) throws IOException {
    this.context = context;
    byte tag;

    int count = stream.readUnsignedShort();
    entries = new ClassfileConstant[count];

    int i = 1;
    while (i < count) {
        entries[i] = readConstant(stream);
        tag = entries[i].tag;

        if ((tag == ClassfileConstant.CONSTANT_Double) || (tag == ClassfileConstant.CONSTANT_Long)) {
            i += 2;
        } else {
            i += 1;
        }
    }
}
 
Example #18
Source File: RecoveryMarker.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void readWire(final DataInputStream in) throws IOException, ClassNotFoundException {

   super.readWire(in);

   //
   newClusterUUID = SerializerUtils.readUuid(in);

   // Originator
   originator = SerializerUtils.readAddress(in);

   // current list
   final int currentListSize = in.readInt();
   currentList = new ArrayList<JoiningNode>(currentListSize + 1); // +1 because we know we will add ourselves
   for (int i = 0; i < currentListSize; i++) {
      currentList.add(SerializerUtils.readJoiningNode(in));
   }

   // previous list
   final int previousListSize = in.readInt();
   previousList = new ArrayList<JoiningNode>(previousListSize);
   for (int i = 0; i < previousListSize; i++) {
      previousList.add(SerializerUtils.readJoiningNode(in));
   }
}
 
Example #19
Source File: TestHLLSerialization.java    From hyperloglog with Apache License 2.0 6 votes vote down vote up
@Test
public void testHLLDenseSerializationHalfDistinct() throws IOException {
  HyperLogLog hll = HyperLogLog.builder().setEncoding(EncodingType.DENSE).build();
  Random rand = new Random(SEED);
  Set<Integer> hashset = new HashSet<Integer>();
  for (int i = 0; i < size; i++) {
    int val = rand.nextInt(size / 2);
    hll.addLong(val);
    hashset.add(val);
  }
  FileOutputStream fos = new FileOutputStream(testFile);
  DataOutputStream out = new DataOutputStream(fos);
  HyperLogLogUtils.serializeHLL(out, hll);
  double threshold = size > 40000 ? longRangeTolerance : shortRangeTolerance;
  double delta = threshold * hashset.size() / 100;
  FileInputStream fis = new FileInputStream(testFile);
  DataInputStream in = new DataInputStream(fis);
  HyperLogLog deserializedHLL = HyperLogLogUtils.deserializeHLL(in);
  assertEquals(hll, deserializedHLL);
  assertEquals(hll.toString(), deserializedHLL.toString());
  assertEquals(hll.toStringExtended(), deserializedHLL.toStringExtended());
  assertEquals(hll.hashCode(), deserializedHLL.hashCode());
  assertEquals(hll.count(), deserializedHLL.count());
  assertEquals(hashset.size(), hll.count(), delta);
  assertEquals(hashset.size(), deserializedHLL.count(), delta);
}
 
Example #20
Source File: TestDataBlockEncoders.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void testAlgorithm(byte[] encodedData, ByteBuffer unencodedDataBuf,
    DataBlockEncoder encoder) throws IOException {
  // decode
  ByteArrayInputStream bais = new ByteArrayInputStream(encodedData, ENCODED_DATA_OFFSET,
      encodedData.length - ENCODED_DATA_OFFSET);
  DataInputStream dis = new DataInputStream(bais);
  ByteBuffer actualDataset;
  HFileContext meta = new HFileContextBuilder().withHBaseCheckSum(false)
      .withIncludesMvcc(includesMemstoreTS).withIncludesTags(includesTags)
      .withCompression(Compression.Algorithm.NONE).build();
  actualDataset = encoder.decodeKeyValues(dis, encoder.newDataBlockDecodingContext(meta));
  actualDataset.rewind();

  // this is because in case of prefix tree the decoded stream will not have
  // the
  // mvcc in it.
  assertEquals("Encoding -> decoding gives different results for " + encoder,
      Bytes.toStringBinary(unencodedDataBuf), Bytes.toStringBinary(actualDataset));
}
 
Example #21
Source File: TrieDictionaryTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
private static TrieDictionary<String> testSerialize(TrieDictionary<String> dict) {
    try {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        DataOutputStream dataout = new DataOutputStream(bout);
        dict.write(dataout);
        dataout.close();
        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
        DataInputStream datain = new DataInputStream(bin);
        TrieDictionary<String> r = new TrieDictionary<String>();
        r.readFields(datain);
        datain.close();
        return r;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #22
Source File: catchBase.java    From Android-Music-Player with MIT License 6 votes vote down vote up
public ArrayList<String[]> readArrayList(DataInputStream Din) throws IOException {
    int arLen = Din.readInt();
    ArrayList<String[]> ar = null;
    if(arLen > 0){
        ar = new ArrayList<String[]>();
    }
    for(int i = 0;i < arLen;i++){
        int sLen = Din.readInt();
        String[] sr = new String[sLen];
        for(int j = 0;j < sLen;j++) {
            sr[j] = Din.readUTF();
        }
        ar.add(sr);
    }
    return  ar;
}
 
Example #23
Source File: HeaderDecoder.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
/**
    * Reads PLM marker segment and realigns the codestream where the next
    * marker should be found. Informations stored in these fields are
    * currently not taken into account.
    *
    * @param ehs The encoder header stream.
    *
    * @exception IOException If an I/O error occurs while reading from the
    * encoder header stream
    * */
   private void readPLM(DataInputStream ehs) throws IOException{
int length;

length = ehs.readUnsignedShort();
//Ignore all informations contained
ehs.skipBytes(length-2);

       FacilityManager.getMsgLogger().
           printmsg(MsgLogger.INFO,"Skipping unsupported PLM marker");
   }
 
Example #24
Source File: PageHintReaderV2.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected InstanceIndex[] readInstanceIndex( DataInputStream in )
		throws IOException
{
	int length = IOUtil.readInt( in );
	InstanceIndex[] indexes = new InstanceIndex[length];
	for ( int i = 0; i < length; i++ )
	{
		String id = IOUtil.readString( in );
		long offset = IOUtil.readLong( in );
		indexes[i] = new InstanceIndex( InstanceID.parse( id ), offset );
	}
	return indexes;
}
 
Example #25
Source File: PieceHolder.java    From Klooni1010 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void read(DataInputStream in) throws IOException {
    // If the saved piece count does not match the current piece count,
    // then an IOException is thrown since the data saved was invalid
    final int savedPieceCount = in.readInt();
    if (savedPieceCount != count)
        throw new IOException("Invalid piece count saved.");

    for (int i = 0; i < count; i++)
        pieces[i] = in.readBoolean() ? Piece.read(in) : null;
    updatePiecesStartLocation();
}
 
Example #26
Source File: DataInputStreamUtils.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public static Direction decodeDirection(DataInputStream in) throws IOException {
    byte direction = in.readByte();
    switch (direction) {
        case 'I':
            return Direction.IN;
        case 'O':
            return Direction.OUT;
        default:
            throw new VertexiumAccumuloIteratorException(String.format("Unhandled direction: 0x%02x", direction));
    }
}
 
Example #27
Source File: UndeleteRequest.java    From ambry with Apache License 2.0 5 votes vote down vote up
public static UndeleteRequest readFrom(DataInputStream stream, ClusterMap map) throws IOException {
  Short version = stream.readShort();
  if (version != UNDELETE_REQUEST_VERSION_1) {
    throw new IllegalStateException("Unknown undelete request version " + version);
  }
  int correlationId = stream.readInt();
  String clientId = Utils.readIntString(stream);
  BlobId id = new BlobId(stream, map);
  long operationTimeMs = stream.readLong();
  return new UndeleteRequest(correlationId, clientId, id, operationTimeMs);
}
 
Example #28
Source File: HyperLogLog.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static HyperLogLog build(byte[] bytes) throws IOException
{
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    DataInputStream oi = new DataInputStream(bais);
    int log2m = oi.readInt();
    int size = oi.readInt();
    byte[] longArrayBytes = new byte[size];
    oi.readFully(longArrayBytes);
    return new HyperLogLog(log2m, new RegisterSet((int) Math.pow(2, log2m), Bits.getBits(longArrayBytes)));
}
 
Example #29
Source File: DnsMessageTransport.java    From nomulus with Apache License 2.0 5 votes vote down vote up
private Message readMessage(InputStream inputStream) throws IOException {
  DataInputStream stream = new DataInputStream(inputStream);
  int length = stream.readUnsignedShort();
  byte[] messageData = new byte[length];
  stream.readFully(messageData);
  return new Message(messageData);
}
 
Example #30
Source File: TestMapReduce.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static boolean isSequenceFile(FileSystem fs,
                                      Path f) throws IOException {
  DataInputStream in = fs.open(f);
  try {
    byte[] seq = "SEQ".getBytes();
    for (int i = 0; i < seq.length; ++i) {
      if (seq[i] != in.read()) {
        return false;
      }
    }
  } finally {
    in.close();
  }
  return true;
}