Java InputStream Deserialize to Object deserializeUUID(InputStream in)

Here you can find the source of deserializeUUID(InputStream in)

Description

deserialize UUID

License

Open Source License

Declaration

public static UUID deserializeUUID(InputStream in) 

Method Source Code


//package com.java2s;
/* // w ww . j  av  a 2 s. com
 * This file is part of the HyperGraphDB source distribution. This is copyrighted 
 * software. For permitted uses, licensing options and redistribution, please see  
 * the LicensingInformation file at the root level of the distribution.  
 * 
 * Copyright (c) 2005-2010 Kobrix Software, Inc.  All rights reserved. 
 */

import java.io.IOException;
import java.io.InputStream;

import java.util.UUID;

public class Main {
    public static UUID deserializeUUID(InputStream in) {
        byte[] data = new byte[16];

        try {
            in.read(data);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        long msb = 0;
        long lsb = 0;

        for (int i = 0; i < 8; i++)
            msb = (msb << 8) | (data[i] & 0xff);
        for (int i = 8; i < 16; i++)
            lsb = (lsb << 8) | (data[i] & 0xff);
        return new UUID(msb, lsb);

    }
}

Related

  1. deserialize(String input, Class tClass)
  2. deserializeFromStram(InputStream inputStram)
  3. deserializeFromStream(ObjectInputStream in)
  4. deserializeInt(InputStream in)
  5. deserializeSpecial(InputStream is, Class clazz)