Datasets:
ArXiv:
License:
Stack-Repo / data /train /akash-coded /FSD_Java /Lesson-3 /File Handling /Examples /FileFunctionsDemo.java
Download data/train/akash-coded/FSD_Java/Lesson-3/File Handling/Examples/FileFunctionsDemo.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 949 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/File%20Handling/Examples/FileFunctionsDemo.java
- Command line
-
hf download 'hf://datasets/RepoFusion/Stack-Repo@bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/File Handling/Examples/FileFunctionsDemo.java'
-
curl -L -o FileFunctionsDemo.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/File%20Handling/Examples/FileFunctionsDemo.java
949 Bytes
| import java.io.*; | |
| public class FileFunctionsDemo { | |
| public static void main(String[] args) { | |
| String path = ""; | |
| boolean bool = false; | |
| try { | |
| // createing new files | |
| File file = new File("testFile1.txt"); | |
| file.createNewFile(); | |
| System.out.println(file); | |
| // createing new canonical from file object | |
| File file2 = file.getCanonicalFile(); | |
| // returns true if the file exists | |
| System.out.println(file2); | |
| bool = file2.exists(); | |
| // returns absolute pathname | |
| path = file2.getAbsolutePath(); | |
| System.out.println(bool); | |
| // if file exists | |
| if (bool) { | |
| // prints | |
| System.out.print(path + " Exists? " + bool); | |
| } | |
| } catch (Exception e) { | |
| // if any error occurs | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | |