Here you can find the source of newGzipBufferedWriter(Path path)
Parameter | Description |
---|---|
path | to be read |
Parameter | Description |
---|---|
IOException | an exception |
public static BufferedWriter newGzipBufferedWriter(Path path) throws IOException
//package com.java2s; /*// w ww .ja v a2 s . c o m * Copyright 2015 OpenCB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.*; import java.nio.file.Path; import java.util.zip.GZIPOutputStream; public class Main { /** * This method is able to determine whether a file is GZipped and return a BufferedReader in any case * @param path to be read * @return BufferedReader object * @throws IOException */ public static BufferedWriter newGzipBufferedWriter(Path path) throws IOException { return new BufferedWriter( new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(path.toFile())))); } }