Java Path File Write nio newGzipBufferedWriter(Path path)

Here you can find the source of newGzipBufferedWriter(Path path)

Description

This method is able to determine whether a file is GZipped and return a BufferedReader in any case

License

Apache License

Parameter

Parameter Description
path to be read

Exception

Parameter Description
IOException an exception

Return

BufferedReader object

Declaration

public static BufferedWriter newGzipBufferedWriter(Path path) throws IOException 

Method Source Code


//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()))));
    }
}

Related

  1. checkFilePermissions(final String filepath, final boolean canRead, final boolean canWrite)
  2. compareTable(final String table, final List d1, final List d2, final BufferedWriter errors)
  3. isWritePermission(Path p)
  4. newBufferedWriter(Path path)
  5. newBufferedWriter(Path path, OpenOption... options)
  6. okayToOverwrite(Path file)
  7. overwriteFile(final String newFilePath, final String oldFilePath)
  8. removeMatchingLines( final Map d1LineMap, final Path tableDir, final String table, final BufferedWriter errors)
  9. robustCheckWriteable(Path logFile)