{"id":18614951,"url":"https://github.com/andrewjbateman/java-nio-files","last_synced_at":"2025-09-02T04:08:49.723Z","repository":{"id":96860403,"uuid":"364979764","full_name":"AndrewJBateman/java-nio-files","owner":"AndrewJBateman","description":":clipboard: Java code to access data in files using NIO File classes","archived":false,"fork":false,"pushed_at":"2021-05-12T13:34:42.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-17T01:34:27.739Z","etag":null,"topics":["filesystem","intellij-idea","java","java-11","nio","udemy-tutorial"],"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/AndrewJBateman.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}},"created_at":"2021-05-06T16:56:33.000Z","updated_at":"2022-01-11T22:04:31.000Z","dependencies_parsed_at":"2023-03-30T11:35:50.507Z","dependency_job_id":null,"html_url":"https://github.com/AndrewJBateman/java-nio-files","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AndrewJBateman/java-nio-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fjava-nio-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fjava-nio-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fjava-nio-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fjava-nio-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndrewJBateman","download_url":"https://codeload.github.com/AndrewJBateman/java-nio-files/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fjava-nio-files/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273228067,"owners_count":25067713,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["filesystem","intellij-idea","java","java-11","nio","udemy-tutorial"],"created_at":"2024-11-07T03:27:38.035Z","updated_at":"2025-09-02T04:08:49.709Z","avatar_url":"https://github.com/AndrewJBateman.png","language":"Java","readme":"# :zap:Java NIO\n \n* Java coding project for a Java Programming Masterclass see [:clap: Inspiration](#clap-inspiration) below\n\n*** Note: to open web links in a new window use: _ctrl+click on link_**\n\n## :page_facing_up: Table of contents\n\n* [:zap: Angular Material Table](#zap-angular-material-table)\n  * [:page_facing_up: Table of contents](#page_facing_up-table-of-contents)\n  * [:books: General info](#books-general-info)\n  * [:camera: Screenshots](#camera-screenshots)\n  * [:signal_strength: Technologies](#signal_strength-technologies)\n  * [:floppy_disk: Setup](#floppy_disk-setup)\n  * [:computer: Code Examples](#computer-code-examples)\n  * [:cool: Features](#cool-features)\n  * [:clipboard: Status \u0026 To-Do List](#clipboard-status--to-do-list)\n  * [:clap: Inspiration](#clap-inspiration)\n  * [:envelope: Contact](#envelope-contact)\n\n## :books: General info\n\n* [Java.nio](https://docs.oracle.com/javase/8/docs/api/java/nio/package-summary.html) used to define buffers - containers for data.\n* [Java.nio FileSystem class](https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html) provides an interface to a file system.\n* [Java.nio IntBuffer class](https://docs.oracle.com/javase/9/docs/api/java/nio/IntBuffer.html) extends Buffer, an int buffer\n* [Java.nio flip()](https://www.geeksforgeeks.org/buffer-flip-methods-in-java-with-examples/) to flip buffer. Use after read and before write operations\n* [Java Pipe class](https://docs.oracle.com/javase/7/docs/api/java/nio/channels/Pipe.html) 2 channels that implement a unidirectional pipe, a writable sink channel and a readable source channel.\n* [Java lambda expression](https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html) a single method class - to take in parameters and return a value.\n\n## :camera: Screenshots\n\n* Not applicable for this project\n\n## :signal_strength: Technologies\n\n* [Java v11](https://www.java.com/en/)\n\n## :floppy_disk: Setup\n\n* Open folder in an IDE such as IntelliJ.\n\n## :computer: Code Examples\n\n* class to create a data file and write data to it. flip() method used to flip the buffer so buffer trimmed to current position then position changed to zero.\n\n```java\npublic class Main {\n\n  public static void main(String[] args) {\n    try(FileOutputStream binFile = new FileOutputStream(\"data.dat\");\n        FileChannel binChannel = binFile.getChannel()) {\n\n      byte[] outputBytes = \"Hello World\".getBytes();\n      ByteBuffer buffer = ByteBuffer.wrap(outputBytes);\n      int numBytes = binChannel.write(buffer);\n      System.out.println(\"numBytes written was: \" + numBytes);\n\n      ByteBuffer intBuffer = ByteBuffer.allocate(Integer.BYTES);\n      intBuffer.putInt(245);\n      intBuffer.flip();\n      numBytes = binChannel.write(intBuffer);\n      System.out.println(\"numBytes written was: \" + numBytes);\n\n      intBuffer.flip();\n      intBuffer.putInt(-98765);\n      intBuffer.flip();\n      numBytes = binChannel.write(intBuffer);\n      System.out.println(\"numBytes written was: \" + numBytes);\n    } catch(IOException e) {\n      e.printStackTrace();\n    }\n  }\n}\n```\n\n## :cool: Features\n\n* tba\n\n## :clipboard: Status \u0026 To-Do List\n\n* Status: Working tutorial code Section 14-247 completed.\n* To-Do: Complete tutorial\n\n## :clap: Inspiration\n\n* [Udemy: Java Programming Masterclass for Software Developers](https://www.udemy.com/course/java-the-complete-java-developer-course/learn/lecture/3561816#overview)\n\n## :envelope: Contact\n\n* Repo created by [ABateman](https://www.andrewbateman.org), email: gomezbateman@yahoo.com\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewjbateman%2Fjava-nio-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewjbateman%2Fjava-nio-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewjbateman%2Fjava-nio-files/lists"}