A space for Automation Enthusiasts. Tutorials for beginners, tips for experts and updates on testing technologies!
Tuesday, November 08, 2011
Create file and overwrite if it exists
Create file if it does not exist
The following code 'll create a file 'examplefile.txt',if doesn't exist
- try {
- // Create file if it does not exist
- boolean success = file.createNewFile();
- if (success) {
- // File did not exist and was created
- } else {
- // File already exists
- }
- e.printStackTrace();
- }
Subscribe to:
Posts (Atom)