1String yourFile = "YourFile.txt";
2String yourContent = "YourContent"
3
4File tmpDir = new File(yourFile);
5boolean exists = tmpDir.exists();
6
7if(!exists) {
8 FileOutputStream fos = new FileOutputStream(yourFile);
9 fos.write(yourContent.getBytes());
10 fos.flush();
11 fos.close();
12}
1File yourFile = new File("score.txt");
2yourFile.createNewFile(); // if file already exists will do nothing
3FileOutputStream oFile = new FileOutputStream(yourFile, false);