Java Path Create nio createAndGetOutputStream(String typename, String outputPath)

Here you can find the source of createAndGetOutputStream(String typename, String outputPath)

Description

create And Get Output Stream

License

Apache License

Declaration

public static Writer createAndGetOutputStream(String typename, String outputPath) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

import java.nio.charset.Charset;

public class Main {
    public static Writer createAndGetOutputStream(String typename, String outputPath) throws IOException {
        if (typename.indexOf('$') > 0) {
            System.out.println(typename);
            typename = typename.substring(0, typename.lastIndexOf('.')) + "."
                    + typename.substring(typename.indexOf('$') + 1);
        }//  www  . ja va2s.  co m
        File file = new File(outputPath, typename.replace('.', File.separatorChar) + ".java");
        file.getParentFile().mkdirs();
        file.createNewFile();
        OutputStream os = new FileOutputStream(file);
        return new OutputStreamWriter(os, Charset.forName("UTF-8"));
    }
}

Related

  1. clearAndCreate(Path dir)
  2. createACL(Path root, Path p, GroupPrincipal readOnly, GroupPrincipal readWrite)
  3. createBufferedReader(Path path)
  4. createChecksums(final Path file, final Map functions)
  5. createClassWithDepsNextExtra(int index, Path dir)
  6. createDir(Path p)