Open a BufferedWriter
@param errFilePath path to write the file
773598
public void open(Path errFilePath) throws IOException {
    this.fs.mkdirs(errFilePath.getParent());
    OutputStream os =
        this.closer.register(this.fs.exists(errFilePath) ? this.fs.append(errFilePath) : this.fs.create(errFilePath));
    this.writer = this.closer
        .register(new BufferedWriter(new OutputStreamWriter(os, ConfigurationKeys.DEFAULT_CHARSET_ENCODING)));
  }
559546
public static function writeFile($strFilePath, $strContents)
    {
        $fileHandle = fopen($strFilePath, "w");
        if (!$fileHandle) {
            throw new \Exception("Cannot open file for writing: " . $strFilePath);
        }

        if (fwrite($fileHandle, $strContents, strlen($strContents)) === false) {
            throw new \Exception("Unable to write file: " . $strFilePath);
        }
        fclose($fileHandle);
    }
825521
public static void createFileWithSparse(String filePath, long length) throws IOException {
    Path path = Paths.get(filePath);
    try {
      Files.deleteIfExists(path);
      try (
          SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, StandardOpenOption.SPARSE)
      ) {
        channel.position(length - 1);
        channel.write(ByteBuffer.wrap(new byte[]{0}));
      }
    } catch (IOException e) {
      throw new IOException("create spares file fail,path:" + filePath + " length:" + length, e);
    }
  }
712424
public void NeEvl(String outputPath) throws IOException{


		String res = "";
		res += calcByLength()+"\n";
		res += calcByType()+"\n";
		res += calcByOOV()+"\n";
		res += calcByCOOV()+"\n";
		res += calcByOOV2()+"\n";
		res += calcByOOVRate()+"\n";



		if(outputPath != null ){
			File outFile =new File(outputPath);
			Writer out=new OutputStreamWriter(new FileOutputStream(outFile));
			out.write(res);
			out.close();
		}

	}
529963
@GwtIncompatible("Unnecessary")
  private Writer openExternExportsStream(B options, String path) throws IOException {
    if (options.externExportsPath == null) {
      return null;
    }

    String exPath = options.externExportsPath;

    if (!exPath.contains(File.separator)) {
      File outputFile = new File(path);
      exPath = outputFile.getParent() + File.separatorChar + exPath;
    }

    return fileNameToOutputWriter2(exPath);
  }
1192680
public void write(String path, String value) throws InterruptedException, KeeperException {

        int retries = 0;
        while (true) {

            try {

                Stat stat = zk.exists(path, false);

                if (stat == null) {

                    zk.create(path, value.getBytes(CHARSET), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

                } else {

                    zk.setData(path, value.getBytes(CHARSET), stat.getVersion());
                }

                break;

            } catch (KeeperException.SessionExpiredException e) {

                throw e;

            } catch (KeeperException e) {

                LOGGER.warn("write connect lost... will retry " + retries + "\t" + e.toString());

                if (retries++ == MAX_RETRIES) {
                    throw e;
                }
                // sleep then retry
                int sec = RETRY_PERIOD_SECONDS * retries;
                LOGGER.warn("sleep " + sec);
                TimeUnit.SECONDS.sleep(sec);
            }
        }
    }
350424
public void writeFile(File inputFile, String jarPath) throws IOException {

		// Get an input stream on the file.
		FileInputStream fis = new FileInputStream(inputFile);
		try {
			// create the zip entry
			JarEntry entry = new JarEntry(jarPath);
			entry.setTime(inputFile.lastModified());
			writeEntry(fis, entry);

		} finally {
			// close the file stream used to read the file
			fis.close();
		}
	}
1336092
public static Writer buildBufferedAppendWriter(Path path, Charset charset) {
        try {
            if (JMPath.notExists(path))
                JMPathOperation.createFileWithParentDirectories(path);
            return Files.newBufferedWriter(path, charset, StandardOpenOption
                    .APPEND);
        } catch (IOException e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "buildBufferedAppendWriter", path, charset);
        }
    }
394257
public void setFilePath(String filePath)
    {
        //create a new file
        File fileInstance=null;
        if(filePath!=null)
        {
            fileInstance=new File(filePath);
        }
        
        //set file
        this.setFile(fileInstance);
    }
757948
public boolean open() throws RasterWritingFailureException {
        boolean ok;
        if (mapPath != null) {
            ok = writer.open(mapPath);
        } else if (locationPath != null && mapsetName != null && mapName != null) {
            ok = writer.open(mapName, locationPath, mapsetName);
        } else {
            return false;
        }

        return ok;
    }
427495
public Path write(Path path) throws IOException {
        write(Files.newOutputStream(path));
        return path;
    }
1268876
private void createDirAndFile(Path path) throws IOException {
			// create dir and file first if dir/file not exist
			File file = new File(path.toAbsolutePath().toString());
			File dir = file.getParentFile();
			if (dir != null && !dir.exists()) {
				dir.mkdirs();
			}
			if (!file.exists()) {
				file.createNewFile();
			}
	}
1015512
private static BufferedReader open(final String path) throws IOException {
    if (path.equals("-")) {
      return new BufferedReader(new InputStreamReader(System.in));
    }

    InputStream is = new FileInputStream(path);
    if (path.endsWith(".gz")) {
      is = new GZIPInputStream(is);
    }
    // I <3 Java's IO library.
    return new BufferedReader(new InputStreamReader(is));
  }
1204742
public void openReadWrite(ReadStreamOld is, WriteStreamOld os) throws IOException
  {
    getWrappedPath().openReadWrite(is, os);
  }
322751
public static void AssertLegalLocalFilePath(String localFilePath) throws ParamException {
        if (localFilePath == null || !CommonFileUtils.isLegalFile(localFilePath)) {
            throw new ParamException(localFilePath + " is not file or not exist or can't be read!");
        }
    }
929135
private static void loadFile(String filePath) {
        final Path path = FileSystems.getDefault().getPath(filePath);

        try {
            data.clear();
            data.load(Files.newBufferedReader(path));
        } catch(IOException e) {
            LOG.warn("Exception while loading " + path.toString(), e);
        }
    }
147851
public static void writeToStream(String fullFilePath, OutputStream out) throws IORuntimeException {
		writeToStream(touch(fullFilePath), out);
	}