These are the related questions that might cause my question to be closed, even though I specify another question:
- Java: How to write binary files? -> Doesn't really cover the point that I am talking about
- create a binary file -> Absolutely doesn't cover the point
- Editing a binary file in java -> They are talking about offsets and stuff, when I just need to write the data and stop
- Binary files in java -> Vague.
And now to the point. I've got a file with a specific extension, to be more exact it's .nbs
. I want to create a file and then write the specific data to it.
That might have sounded vague so let me show you the code I have started with.
try {
File bpdn = new File(getDataFolder() + "song.nbs");
if (!bpdn.exists()) {
bpdn.createNewFile();
}
FileOutputStream fos = new FileOutputStream(bpdn);
} catch (IOException e) {
e.printStackTrace();
}
I'll provide you even more details. So I've got a song.nbs
file that I have created in the past, for myself. And now, whenever a person runs my application, I want it so there's a new song.nbs
file with the exact contents of a file that I have on my PC right now. Therefore, I need to somehow get the bytes of my existing song.nbs
and then copy and paste them in my Java application... or is it the way? I neither know how to get the bytes of my own file right now, nor do I know how to write them.