java - File Processing -


i'm writing game in user can create own level , remove them also. trouble want files saved names level1, level2, level3 etc without asking user name of level.

while saving game level5 name might possible previous level name exists. there way avoid such problems. mean before saving name should save should known previously...

thanx...

you can make use of methods provided java.io.file api, such file#exists(). returns boolean. if true, can either append file, or create 1 different filename (maybe counter suffix?). can append existing file using constructor of fileoutputstream taking 2nd boolean argument set true. can stick using constructor without checking if file exists, create new 1 if file doesn't exist , append if file exists.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -