Datasets:
ArXiv:
License:
Stack-Repo / data /train /akash-coded /FSD_Java /Lesson-3 /File Handling /Examples /FileStreamTest.java
Download data/train/akash-coded/FSD_Java/Lesson-3/File Handling/Examples/FileStreamTest.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 650 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/File%20Handling/Examples/FileStreamTest.java
- Command line
-
hf download 'hf://datasets/RepoFusion/Stack-Repo@bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/File Handling/Examples/FileStreamTest.java'
-
curl -L -o FileStreamTest.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/File%20Handling/Examples/FileStreamTest.java
650 Bytes
| import java.io.*; | |
| public class FileStreamTest { | |
| public static void main(String args[]) { | |
| try (OutputStream os = new FileOutputStream("test.txt"); InputStream is = new FileInputStream("test.txt");) { | |
| byte[] bWrite = { 65, 90, 48, 57, 97, 122 }; | |
| for (int x = 0; x < bWrite.length; x++) { | |
| os.write(bWrite[x]); // writes the bytes | |
| } | |
| int size = is.available(); | |
| for (int i = 0; i < size; i++) { | |
| System.out.print((char) is.read() + " "); | |
| } | |
| } catch (IOException e) { | |
| System.out.println("Exception"); | |
| } | |
| } | |
| } | |