Java ClassLoader Load getSSTable(String version, int generation)

Here you can find the source of getSSTable(String version, int generation)

Description

get SS Table

License

Apache License

Declaration

public static File getSSTable(String version, int generation)
            throws Exception 

Method Source Code

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

import com.google.common.io.ByteStreams;
import java.io.File;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URLClassLoader;

public class Main {
    public static File getSSTable(String version, int generation)
            throws Exception {
        copyResource(version + "-" + generation + "-big-Digest.crc32");
        copyResource(version + "-" + generation + "-big-TOC.txt");
        copyResource(version + "-" + generation + "-big-CompressionInfo.db");
        copyResource(version + "-" + generation + "-big-Filter.db");
        copyResource(version + "-" + generation + "-big-Index.db");
        copyResource(version + "-" + generation + "-big-Statistics.db");
        copyResource(version + "-" + generation + "-big-Summary.db");
        copyResource(version + "-" + generation + "-big-TOC.txt");
        return copyResource(version + "-" + generation + "-big-Data.db");
    }/*from  www.jav  a  2  s. c om*/

    private static File copyResource(String name) throws Exception {
        InputStream is = URLClassLoader.getSystemResourceAsStream(name);
        String tempDir = System.getProperty("java.io.tmpdir");
        File tmp = new File(tempDir + File.separator + name);
        tmp.deleteOnExit();
        ByteStreams.copy(is, new FileOutputStream(tmp));
        return tmp;
    }
}

Related

  1. getProperty(String propertyName)
  2. getReader(final String name, final String encoding)
  3. getRootPath()
  4. getSimpleName(String fqcn)
  5. getSourcesPath()
  6. getStream(final File file)
  7. getStreamForString(String source)
  8. getSystemPath(String inPath)
  9. getTestDir(final String name)