zhouheidz
zhouheidz

Reputation: 47

Should I save a music playlist as binary or text file in java?

I'm currently making my own music player in Java (NetBeans IDE), and I'm working out on the playlist, storing the file paths in an array. Should I save those file paths as binary or text? Because I plan on having a "save" and "load" button that would save and load a playlist.

Upvotes: 1

Views: 426

Answers (4)

IntrepidPig
IntrepidPig

Reputation: 110

It depends on whether or not you want the user to be able to open and read the playlist file. Humans can't read binary files, so you should probably use a text file unless you want the contents to be unreadable.

Upvotes: 0

Elliott Frisch
Elliott Frisch

Reputation: 201457

My advice, use the "cue" sheet format (which is ascii) - from the Wikipedia article, A cue sheet is a plain text file containing commands with one or more parameters.

Essential commands

FILE

Names a file containing the data and its format (such as MP3, and WAVE audio file formats, and plain "binary" disc images)

TRACK

Defines a track context, providing its number and type or mode (for instance AUDIO or various CD-ROM modes). Some commands that follow this command apply to the track rather than the entire disc.

INDEX

Indicates an index (position) within the current FILE. The position is specified in mm:ss:ff (minute-second-frame) format. There are 75 such frames per second of audio. In the context of cue sheets, "frames" refer to CD sectors, despite a different, lower-level structure in CDs also being known as frames.[5] INDEX 01 is required and denotes the start of the track, while INDEX 00 is optional and denotes the pregap. The pregap of Track 1 is used for Hidden Track One Audio (HTOA). Optional higher-numbered indexes (02 through 99) are also allowed.

PREGAP and POSTGAP

Indicates the length of a track's pregap or postgap, which is not stored in any data file. The length is specified in the same minute-second-frame format as for INDEX.

Upvotes: 2

You should always prefer human-readable formats when possible. JSON, XML, or line-oriented text are all good options.

Upvotes: 0

Barett
Barett

Reputation: 5948

Actually, you will probably find it more convenient to use File[] or Path[].

Prefer text over binary though.

Upvotes: 0

Related Questions