You can write the data to OutputStream like this:
DataOutputStream output = null;
try {
output = new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(new File("output.dat"))));
output.writeUTF(time);
output.writeLong(latitude);
output.writeLong(longitude);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
if (output != null)
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}