Question

i am working on a RFID project, in which i should identify vehicles with their RFID tag. the RFID Tags contain 14 bytes of data. my first clue was to convert each byte of the array to string something like this :

public String convertByteToString(byte[] tag)
{
    String stringRfid ="";
    for(int i=0; i<14; i++)
      stringRfid = stringRfid + tag[i];
    return stringRfid;
}

i don't know if this is a humble solution or what. some say and i quote it "storing raw byte[] in BLOB - the safest and most storage-effective way." would you please give me tip what is the fastest and easiest and also efficient way to do this?

Was it helpful?

Solution

I would transform the byte array to a base64-encoded readable string, and store this string in the database. It would only increase the size with a 4/3 ratio (so around 20 bytes instead of 14), and would store readable, indexable and printable ascii strings in the database.

Guava and apache commons-codec both have a free base64 encoder/decoder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top