{"id":20316474,"url":"https://github.com/javinator9889/filetobytesexporter","last_synced_at":"2025-06-15T08:07:14.522Z","repository":{"id":114246988,"uuid":"156072620","full_name":"Javinator9889/FileToBytesExporter","owner":"Javinator9889","description":"Generate binary files from regular text ones","archived":false,"fork":false,"pushed_at":"2018-12-30T19:32:34.000Z","size":563,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T09:14:28.140Z","etag":null,"topics":["binary-file","converter","docs","exporter","fast","files","java8","kafka","parallel","text"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Javinator9889.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-11-04T10:55:12.000Z","updated_at":"2023-01-07T04:30:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"60fadc86-3c35-49b6-ad1d-be8b903688ba","html_url":"https://github.com/Javinator9889/FileToBytesExporter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Javinator9889/FileToBytesExporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javinator9889%2FFileToBytesExporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javinator9889%2FFileToBytesExporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javinator9889%2FFileToBytesExporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javinator9889%2FFileToBytesExporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Javinator9889","download_url":"https://codeload.github.com/Javinator9889/FileToBytesExporter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javinator9889%2FFileToBytesExporter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259942787,"owners_count":22935329,"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":["binary-file","converter","docs","exporter","fast","files","java8","kafka","parallel","text"],"created_at":"2024-11-14T18:26:19.948Z","updated_at":"2025-06-15T08:07:14.499Z","avatar_url":"https://github.com/Javinator9889.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FileToBytesExporter\n*Generate binary files from regular text ones*.\n\n## 1. Introduction - *why this library?*\n\nNowadays, about **~90%** of the digital files are *binary files*. What does it mean? Well, \nbasically a **binary file** is a non-structured file no human readable which has so many \nadvantages facing **regular text files**:\n\n\u003cul\u003e\n\u003cli\u003e\n   \u003cb\u003eMemory efficient\u003c/b\u003e: while \u003ci\u003eplain text files\u003c/i\u003e has 128 possible values (pure\n   unexpanded ASCII), binary files have \u003cb\u003eup to 256 possible values\u003c/b\u003e, so it is twice compact (as\n   for representing some chars in ASCII, more than one value is needed).\n\u003c/li\u003e\n\u003cli\u003e\n   \u003cb\u003eCompact\u003c/b\u003e: storing a \u003ci\u003ebinary file\u003c/i\u003e will necessarily be more packed than a\n   \u003ci\u003eplain text file\u003c/i\u003e.\n\u003c/li\u003e\n\u003cli\u003e\n   \u003cb\u003eNo syntax definition\u003c/b\u003e: as some human-readable files such as \u003ci\u003eXML, JAVA, etc.\n\u003c/i\u003e need a \u003cb\u003especific syntax\u003c/b\u003e for saving data correctly, they increase its size and\n   complexity with that rules. As opposed to that, \u003cb\u003ebinary files\u003c/b\u003e just saves the data, with no\n   modifications or rules, which is faster and memory friendly.\n\u003c/li\u003e\n\u003cli\u003e\n   \u003cb\u003eDirectly to memory\u003c/b\u003e: as there is \u003cb\u003eno need of processing the data\u003c/b\u003e, reading\n   a binary file is as simple as it goes directly to the memory for using it.\n\u003c/li\u003e\n\u003cli\u003e\n   \u003cb\u003eSecure\u003c/b\u003e: as \u003cb\u003ebinary file\u003c/b\u003e is not human-readable file, it makes impossible\n   to others to inspect and know the \u003ci\u003efile contents\u003c/i\u003e without a proper editor. Also they need to\n   know \u003cb\u003ewhich type of data structure\u003c/b\u003e is saved for obtaining the desired instance.\n\u003c/li\u003e\n\u003c/ul\u003e\n\nDefinitely, this library allows you to **convert any text file** to binary one, as fast as \npossible using multiple threads for achieving that purpose. In addition, you will be able to \n**merge multiple files** into *one binary file*, by declaring multiple paths where your file is \nin there, or using **glob syntax** for the same purpose.\n\nIf you need more information, please read the \n[official documentation](https://javinator9889.github.io/FileToBytesExporter/).\n\n## 2. Installation\n\nFor using this library at **any Java application you are using**, you can just *[download from \n\"Releases\"](https://github.com/Javinator9889/FileToBytesExporter/releases)* or use one of the \nfollowing methods:\n\n### Maven\n*First add JCenter to your app*:\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n      \u003cid\u003ejcenter\u003c/id\u003e\n      \u003curl\u003ehttps://jcenter.bintray.com/\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nThen, you can just include the lib:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.javinator9889\u003c/groupId\u003e\n  \u003cartifactId\u003efiletobytesexporter\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.4\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n*First, add JCenter to your app*:\n```groovy\nrepositories {\n    jcenter()\n    // Other repositories you have\n}\n```\n\nThen, you can just include the lib:\n```groovy\nimplementation 'com.github.javinator9889:filetobytesexporter:1.0.4'\n```\n\n### Ivy\n*First, add JCenter to your Ivy settings*:\n```xml\n\u003civysettings\u003e\n    \u003cresolvers\u003e\n        \u003cibiblio name=\"bintray\"\n                 m2compatible=\"true\"\n                 root=\"http://dl.bintray.com/content/example/external-deps\"/\u003e\n    \u003c/resolvers\u003e\n\u003c/ivysettings\u003e\n```\n\nThen, you can just include the lib:\n```xml\n\u003cdependency org='com.github.javinator9889' name='filetobytesexporter' rev='1.0.4'\u003e\n  \u003cartifact name='filetobytesexporter' ext='pom' \u003e\u003c/artifact\u003e\n\u003c/dependency\u003e\n```\n\nYou must have to **include JCenter()** in order to make it work.\n\n## 3. Usage\n\nAfter [successfully included the library in your project](#2-installation), you must do the following for using this class:\n+ Generate a new `FileToBytesExporter` instance.\n\nIf **generating a new file**:\n+ Setup the source  **filename**.\n+ Setup, if necessary, the **paths** where the source file is in.\n+ Read the source file(s).\n+ Write the *output* file.\n\nIf **obtaining an exported file**:\n+ Read the *output* file.\n+ Obtain the **file separator** (if necessary).\n+ Obtain the **file data**.\n\n### 3.1. Writing a new file\n```java\nimport com.github.javinator9889.exporter.FileToBytesExporter;\n\nimport java.io.File;\nimport java.io.IOException;\n\npublic class YourClassName {\n    public void generateNewFile() {\n        FileToBytesExporter exporter = new FileToBytesExporter();\n        /* Alternatively, you can use the constructor providing \n           directly the \"filename\" and the \"paths\"\n         */\n        String filename = \"inputFile.txt\";\n        exporter.setFilename(filename);\n        exporter.setPaths(\"path1\", \"path2\", \"...\");\n        // == new FileToBytesExporter(filename, \"path1\", \"path2\", \"...\");\n        try{\n            exporter.readSource(); // ALWAYS NEEDED WHEN EXPORTING\n            // Can throw: MultipleFilesFoundError\n            //            InvalidPathException\n            //            FileNotFoundException\n            //            IOException\n            \n            // If reading more than one file:\n            exporter.readSource(true);\n            \n            // Custom file separator:\n            exporter.readSource(true, \"####\");\n            // Both can throw also InvalidFileSeparatorException\n            \n            File destination = new File(\"destinationfile.otxt\");\n            exporter.writeObject(destination);\n        } catch (IOException e) {\n            // Handle error\n            e.printStackTrace();\n        }\n    }\n}\n```\n\n### 3.2. Recovering a file\n\n```java\nimport com.github.javinator9889.exporter.FileToBytesExporter;\nimport com.github.javinator9889.error.FileError;\n\nimport java.io.File;\nimport java.io.IOException;\n\npublic class YourClassName {\n    public void recoverFile() {\n        FileToBytesExporter recover = new FileToBytesExporter();\n        File sourceFile = new File(\"destinationfile.otxt\");\n        try {\n            recover.readObject(sourceFile);\n            String fileSeparator = recover.getFileSeparator();\n            String contents = recover.getReadData();\n            \n            // do work with those variables\n            System.out.println(\"Separator: \" + fileSeparator);\n            System.out.println(\"Contents: \\n\\n\" + contents);\n        } catch (FileError fe) {\n            System.err.println(\"Hashes are not the same\");\n            fe.printStackTrace();\n        } catch (ClassCastException ce) {\n            System.err.println(\"Recovered file is not valid\");\n            ce.printStackTrace();\n        } catch (IOException ioe) {\n            System.err.println(\"File not found or error while reading data\");\n            ioe.printStackTrace();\n        }\n    }\n}\n```\n\n### 3.3. More information\n\nIf you want to know *how are this methods working*, which **exceptions** they are throwing and \n*why*, please read the official documentation:\n\n+ [FileToBytesExporter](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/exporter/FileToBytesExporter.html)\n+ [void readSource](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/exporter/FileToBytesExporter.html#readSource--)\n+ [void writeObject](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/exporter/FileToBytesExporter.html#writeObject-java.io.File-)\n+ [void readObject](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/exporter/FileToBytesExporter.html#readObject-java.io.File-)\n+ [FileError](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/error/FileError.html)\n+ [InvalidFileSeparatorException](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/error/InvalidFileSeparatorException.html)\n+ [InvalidPathException](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/error/InvalidPathException.html)\n+ [MultipleFilesFoundError](https://javinator9889.github.io/FileToBytesExporter/com/github/javinator9889/error/MultipleFilesFoundError.html)\n\n## 4. Contributing\n\nIf you find any error or you want to **add a new feature**, you can perfectly:\n1. Open a **[new issue](https://github.com/Javinator9889/FileToBytesExporter/issues)** completing\n the *issue template* so it will be easier to solve it.\n \n2. Create a new **[pull request](https://github.com/Javinator9889/FileToBytesExporter/pulls)** \nwith the changes you have made to the project, and waiting my approval for merging them.\n## 5. License\n \n     Copyright © 2018 - present | Javinator9889\n \n     This program is free software: you can redistribute it and/or modify\n     it under the terms of the GNU General Public License as published by\n     the Free Software Foundation, either version 3 of the License, or\n     (at your option) any later version.\n \n     This program is distributed in the hope that it will be useful,\n     but WITHOUT ANY WARRANTY; without even the implied warranty of\n     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n     GNU General Public License for more details.\n \n     You should have received a copy of the GNU General Public License\n     along with this program.  If not, see https://www.gnu.org/licenses/.\n     \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavinator9889%2Ffiletobytesexporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavinator9889%2Ffiletobytesexporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavinator9889%2Ffiletobytesexporter/lists"}