{"id":19039811,"url":"https://github.com/shubh2-0/file-handling-in-java","last_synced_at":"2025-04-23T20:48:54.454Z","repository":{"id":171451362,"uuid":"612743115","full_name":"Shubh2-0/File-Handling-In-Java","owner":"Shubh2-0","description":"Discover the Java file handling world with this repository. It features code examples for reading, writing, copying, renaming, and more. Suitable for beginners and experienced developers, it enhances your skills. Embrace the power of Java file handling and elevate your programming journey.","archived":false,"fork":false,"pushed_at":"2023-09-08T11:49:16.000Z","size":45,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T05:53:52.140Z","etag":null,"topics":["create-file","file","file-handling-in-java","java","java-8","java-classes","methods","stream"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shubh2-0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-11T20:58:28.000Z","updated_at":"2024-10-29T15:59:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"c360ab05-0e39-4f41-aea7-05fdac46020f","html_url":"https://github.com/Shubh2-0/File-Handling-In-Java","commit_stats":null,"previous_names":["shubh2-0/file-handling-in-java"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shubh2-0%2FFile-Handling-In-Java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shubh2-0%2FFile-Handling-In-Java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shubh2-0%2FFile-Handling-In-Java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shubh2-0%2FFile-Handling-In-Java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shubh2-0","download_url":"https://codeload.github.com/Shubh2-0/File-Handling-In-Java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513721,"owners_count":21443204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["create-file","file","file-handling-in-java","java","java-8","java-classes","methods","stream"],"created_at":"2024-11-08T22:18:56.253Z","updated_at":"2025-04-23T20:48:54.448Z","avatar_url":"https://github.com/Shubh2-0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# File Handling in Java\n\n📁 A repository showcasing various file handling operations in Java.\n\n## Overview\n\nThis repository provides examples and code snippets for performing file handling operations in Java. File handling is an essential aspect of many Java applications, allowing you to read, write, copy, and manipulate files on the local file system.\n\nFile handling is a critical aspect of any programming language.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/112773220/224777158-8cae1ff0-2d27-4875-9a49-01bd963b28e1.png\" /\u003e\n\nFile handling refers to manipulating files and directories on the file system. This article will provide an overview of file handling in Java.\n```\njava.io.File Class\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/112773220/224777525-f2703db5-93e4-4582-b631-e67cd730867e.png\"/\u003e\n\nThe File class in Java is the primary way to handle files and directories. It is part of the java.io package, which is used for input and output operations.\n\n**The File class has two constructors:**\\\n1️⃣ One that takes a String representing the file path\\\n2️⃣ Another File object representing the file path\n\n\n# This program will display all the contents of a given file on the console .\n```\nimport java.io.*; \npublic class ReadFileExample\n{ \n  public static void main(String args[])\n  { \n    try{\n    File file = new File(\"C:\\\\Users\\\\masai\\\\Desktop\\\\test.txt\");\n      FileReader fr=new FileReader(file);\n      BufferedReader br = new BufferedReader(fr);\n          String s=null;\n          while ((s = br.readLine()) != null)\n          System.out.println(s);\n         }\n\n     catch(Exception ex)\n\n   {\n\n   System.out.println(“Exception=”+ex);\n\n   }\n }\n }\n ```\n \n# Java program to write the contents into a file :\n\n```\nimport java.io.*;\nclass FileWriterDemo\n{ \n    public static void main(String[] args) throws IOException \n    { \n        \n        \n        try{\n           File file = new File(\"C:\\\\Users\\\\sharp\\\\Desktop\\\\out.txt\"); //file being created if it does not exist.     \n           FileWriter fw=new FileWriter(file); \n           fw.write(\"Content to be written\"); \n           fw.close(); \n\t\t   System.out.println(\"File written\"); \n\t\t   }\n\t\t   catch(Exception ex)\n\t\t   {\n\t\t   System.out.println(\"Exception is\"+ex);\n\t\t   }\n\t\t   \n    } \n    ```\n}\n```\n## Contents\n\nThe repository includes the following file handling concepts:\n\n1. 📥 BufferedInputStream: Demonstrates how to efficiently read data from a file using a buffered input stream.\n2. 📤 BufferedWriter: Shows how to write data to a file using a buffered writer.\n3. 📁 FileOperations: Provides various file operations, such as checking file existence, creating a new file, deleting a file, etc.\n4. 📄 FileContentCopy: Illustrates how to copy the contents of one file to another.\n5. 📄 FileMethods: Demonstrates different methods available for working with files, such as getting file size, file last modified timestamp, etc.\n6. 📖 FileReading: Shows how to read the contents of a file using various techniques, including FileReader, FileInputStream, etc.\n7. 🔄 FileRenaming: Provides examples of renaming files in Java.\n8. ✍️ FileWriting: Illustrates how to write content to a file using different methods, such as FileWriter, FileOutputStream, etc.\n9. 📝 ProgramForCreatingFile: Contains a sample program that creates a new file with predefined content.\n\n## Getting Started\n\nTo explore the examples and run the code in this repository, follow these steps:\n\n1. Clone the repository to your local machine using the following command:\n\n   ```bash\n   git clone https://github.com/Shubh2-0/File-Handling-In-Java.git\n   ```\n\n2. Open the cloned directory in your preferred Java IDE.\n\n3. Navigate to the specific file or example you want to explore.\n\n4. Compile and run the Java code to see the file handling operations in action.\n\n## Contributing\n\n🌟 Star this repository if you find it helpful!\n\n---\n\n🔗 [GitHub Repository](https://github.com/Shubh2-0/File-Handling-In-Java.git)\n\n## 📬 Contact\n\nIf you want to contact me, you can reach me through below handles.\n\n \u003cp align=\"left\"\u003e\n  \u003ca href=\"https://www.linkedin.com/in/shubham-bhati-787319213/\" target=\"_blank\"\u003e\u003cimg align=\"center\" src=\"https://skillicons.dev/icons?i=linkedin\" width=\"40px\" alt=\"linkedin\" /\u003e\u003c/a\u003e\u0026emsp;\n  \u003ca title=\"shubhambhati226@gmail.com\" href=\"mailto:shubhambhati226@gmail.com\" target=\"_blank\"\u003e\u003cimg align=\"center\"  src=\"https://cdn-icons-png.flaticon.com/128/888/888853.png\"  width=\"40px\"   alt=\"mail-me\" /\u003e\u003c/a\u003e\u0026emsp;\n  \u003ca href=\"https://wa.me/+916232133187\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://media2.giphy.com/media/Q8I2fYA773h5wmQQcR/giphy.gif\" width=\"40px\"  alt=\"whatsapp-me\" /\u003e\u003c/a\u003e\u0026emsp;\t\n \u003c/p\u003e\n\n\u003cbr\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshubh2-0%2Ffile-handling-in-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshubh2-0%2Ffile-handling-in-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshubh2-0%2Ffile-handling-in-java/lists"}