Created
March 22, 2016 14:23
-
-
Save alexejVasko/d472ff990c300cff7ad5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calculator; | |
import java.io.File; | |
import java.io.IOException; | |
public class FilePath { | |
public static void main(String[] args) { | |
try { | |
String filename = "output.txt"; | |
String workingDirectory = System.getProperty("user.dir"); | |
//****************// | |
String absoluteFilePath; | |
//absoluteFilePath = workingDirectory + System.getProperty("file.separator") + filename; | |
absoluteFilePath = workingDirectory + File.separator + filename; | |
System.out.println("Final filepath : " + absoluteFilePath); | |
//****************// | |
File file = new File(absoluteFilePath); | |
if (file.createNewFile()) { | |
System.out.println("File is created!"); | |
} else { | |
System.out.println("File is already existed!"); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment