{"comment":{"created_at":"2011-10-10T18:21:59Z","body":"Sounds like a useful improvement -- command-line tool was implement in minimal way, and definitely should be possible to add incremental encoder/decoder.","updated_at":"2011-10-10T18:21:59Z","url":"https://api.github.com/repos/ning/compress/issues/comments/2350486","id":2350486,"user":{"avatar_url":"https://secure.gravatar.com/avatar/9a657f7990c2dafca9885dee9c647d4e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/cowtowncoder","id":55065,"login":"cowtowncoder"}},"action":"created","issue":{"number":12,"created_at":"2011-10-10T10:57:05Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"For big files better way is use Input/Output Streams. Very useful will be to add parametr sending results into standard output.\r\n\r\nExample:\r\n-d parameter: decompress to file\r\n-c parameter: compress to file\r\n-o parameter: decompress to output\r\n\r\nExample Java code:\r\n\r\n```java\r\nvoid process(String[] args) throws IOException\r\n    {\r\n        if (args.length == 2) {\r\n            String oper = args[0];\r\n            boolean toSystemOutput = false;\r\n            boolean compress = \"-c\".equals(oper);\r\n            if (\"-o\".equals(oper)) {\r\n            \ttoSystemOutput = true;\r\n            }\r\n            if (compress || \"-d\".equals(oper) || \"-o\".equals(oper)) {\r\n                String filename = args[1];\r\n                File src = new File(filename);\r\n                if (!src.exists()) {\r\n                    System.err.println(\"File '\"+filename+\"' does not exist.\");\r\n                    System.exit(1);\r\n                }\r\n                if (!compress && !filename.endsWith(SUFFIX)) {\r\n                    System.err.println(\"File '\"+filename+\"' does end with expected suffix ('\"+SUFFIX+\"', won't decompress.\");\r\n                    System.exit(1);\r\n                }\r\n                \r\n                InputStream is;\r\n                OutputStream out;\r\n                \r\n                if (!compress) {\r\n                \tis = new LZFFileInputStream(src);\r\n                \tif (toSystemOutput) {\r\n                \t\tout = System.out;\r\n                \t} else {\r\n                \t\tout = new FileOutputStream(new File(filename.substring(0, filename.length() - SUFFIX.length())));\r\n                \t}\r\n                } else {\r\n                \tis = new FileInputStream(src);\r\n                \tout = new LZFFileOutputStream(new File(filename+SUFFIX));\r\n                }\r\n                \r\n                byte[] buffer = new byte[8192];\r\n                int bytesRead = 0;\r\n                while ((bytesRead = is.read(buffer, 0, buffer.length)) != -1) { \r\n                \tout.write(buffer, 0, bytesRead); \r\n                }\r\n                out.flush();\r\n                out.close();\r\n                \r\n                return;\r\n            }\r\n        }\r\n        System.err.println(\"Usage: java \"+getClass().getName()+\" -c/-d/-o file\");\r\n        System.exit(1);\r\n    }\r\n```","comments":1,"title":"Command-line tool out of memory","updated_at":"2011-10-10T18:21:59Z","url":"https://api.github.com/repos/ning/compress/issues/12","id":1863111,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/954ec80631fde0d5a396bd782602e7b8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/nodarret","id":1098625,"login":"nodarret"},"html_url":"https://github.com/ning/compress/issues/12","labels":[],"state":"open"},"legacy":{"issue_id":1863111,"comment_id":2350486}}