Example usage for java.io DataInputStream readLong

List of usage examples for java.io DataInputStream readLong

Introduction

In this page you can find the example usage for java.io DataInputStream readLong.

Prototype

public final long readLong() throws IOException 

Source Link

Document

See the general contract of the readLong method of DataInput.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Long.txt");
    DataInputStream din = new DataInputStream(fin);
    long l = din.readLong();
    System.out.println("long : " + l);
    din.close();//from   w  w  w  .j  a  va  2 s .c o  m
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    long[] l = { 1234567890L, 987654321L };
    FileOutputStream fos = new FileOutputStream("c:\\test.txt");
    DataOutputStream dos = new DataOutputStream(fos);
    for (long j : l) {
        dos.writeLong(j);/*  w w w  .j a  v a  2  s .c  o m*/
    }
    dos.flush();
    InputStream is = new FileInputStream("c:\\test.txt");

    DataInputStream dis = new DataInputStream(is);
    while (dis.available() > 0) {
        long k = dis.readLong();
        System.out.print(k);
    }
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    long[] l = { 1234567898765L, 12345678909876L };

    FileOutputStream fos = new FileOutputStream("c:\\test.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    for (long j : l) {
        dos.writeLong(j);//from  w  w  w.j av a2  s .  co  m
    }
    dos.flush();

    InputStream is = new FileInputStream("c:\\test.txt");
    DataInputStream dis = new DataInputStream(is);

    while (dis.available() > 0) {
        long k = dis.readLong();
        System.out.print(k);
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    try {//from  w ww .j  av a  2 s .  c om

        FileInputStream fis = new FileInputStream("fileName.dat");

        // Create a data input stream
        DataInputStream dis = new DataInputStream(fis);

        // Read and display data
        System.out.println(dis.readBoolean());
        System.out.println(dis.readByte());
        System.out.println(dis.readChar());
        System.out.println(dis.readDouble());
        System.out.println(dis.readFloat());
        System.out.println(dis.readInt());
        System.out.println(dis.readLong());
        System.out.println(dis.readShort());

        // Close file input stream
        fis.close();
    } catch (Exception e) {
        System.out.println("Exception: " + e);
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("myfile.dat");

    DataInputStream din = new DataInputStream(fin);
    while (true) {
        int theNumber = din.readInt();
        //double theNumber = din.readDouble();
        //System.out.println(din.readUTF());
        //boolean b = din.readBoolean();
        byte b = din.readByte();
        System.out.println("byte : " + b);
        System.out.println(theNumber);

        char ch = din.readChar();
        System.out.println("Char : " + ch);
        float f = din.readFloat();
        System.out.println("float : " + f);
        long l = din.readLong();
        System.out.println("long : " + l);

    }//  ww  w  .  ja v  a2 s.c  o  m
}

From source file:Main.java

public static long byteArrayToLong(byte[] input) {
    try {/*w  w  w .j av a  2  s  . c  om*/
        ByteArrayInputStream bis = new ByteArrayInputStream(input);
        DataInputStream dis = new DataInputStream(bis);
        long numb = dis.readLong();
        dis.close();
        return numb;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:PNGDecoder.java

protected static void readSignature(DataInputStream in) throws IOException {
    long signature = in.readLong();
    if (signature != 0x89504e470d0a1a0aL)
        throw new IOException("PNG signature not found!");
}

From source file:net.timewalker.ffmq4.storage.data.impl.journal.JournalRecovery.java

private static CommitOperation readCommitOperation(DataInputStream in) throws IOException {
    long transactionId = in.readLong();
    int operationsCount = in.readInt();

    return new CommitOperation(transactionId, operationsCount, null);
}

From source file:net.timewalker.ffmq4.storage.data.impl.journal.JournalRecovery.java

private static MetaDataWriteOperation readMetaDataWriteOperation(DataInputStream in) throws IOException {
    long transactionId = in.readLong();
    long metaDataOffset = in.readLong();
    int metaData = in.readInt();

    return new MetaDataWriteOperation(transactionId, metaDataOffset, metaData);
}

From source file:net.timewalker.ffmq4.storage.data.impl.journal.JournalRecovery.java

private static StoreExtendOperation readStoreExtendOperation(DataInputStream in) throws IOException {
    long transactionId = in.readLong();
    int blockSize = in.readInt();
    int oldBlockCount = in.readInt();
    int newBlockCount = in.readInt();

    return new StoreExtendOperation(transactionId, blockSize, oldBlockCount, newBlockCount);
}