Dat binary file

How to access a binary data file (.DAT). I am using the geonames API. Can anyone help me?

-2


source to share


2 answers


If you are referring to the flat file binary format used in MaxMinds GeoLocation database, they offer some useful utility classes in C # and Java to access them.



http://www.maxmind.com/app/api

+1


source


Assuming you are using C # (from tag) you can use BinaryReader

class
to read binary data. See How to read and write to a binary file :



FileStream fs = File.Open(Environment.CurrentDirectory + @"\settings.bin", FileMode.Open);
BinaryReader reader = new BinaryReader(fs);

long number = reader.ReadInt64();
byte[] bytes = reader.ReadBytes(3);
string s = reader.ReadString();

reader.Close();
fs.Close();

Console.WriteLine(number);
foreach (byte b in bytes)
{
    Console.Write("[{0}]", b);
}
Console.WriteLine();
Console.WriteLine(s);

      

0


source







All Articles