I am saving Data into a .dat file using this Piece of Code:
void saveFile () {
try {
FileOutputStream fos = new FileOutputStream ("File.dat", true);
DataOutputStream dos = new DataOutputStream (fos);
dos.writeUTF (saves[count][0]);
dos.writeUTF (saves[count][1]);
dos.writeUTF (saves[count][2]);
dos.writeUTF (saves[count][3]);
dos.writeUTF (saves[count][4]);
dos.writeUTF (saves[count][5]);
JOptionPane.showMessageDialog (this, "The Record has been Saved Successfully",
"Record Saved", JOptionPane.PLAIN_MESSAGE);
txtClear ();
dos.close();
fos.close();
}
catch (IOException ioe) {
JOptionPane.showMessageDialog (this, "There are Some Problem with File",
"Problem", JOptionPane.PLAIN_MESSAGE);
}
}
I need to have the .dat File Hosted on some Online Domain Say http://Domain.com/File.dat
What would I need to do to the Piece of code In Order to be able to Accomplish the Save?
1- Either the “domain” is managed on the same server, then you just put the file at the correct place (usually under ‘www’ folder, check your web server configuration)
2- It’s another computer, then you’ll have to transfer the file there (FTP? Another Java piece of code using sockets? API given by the host? …)
Unrelated but you should
closeyourStreamsin afinallyblock