public static File generateTempFileFromResource(final Class<?> graphClass, final Class<?> resourceClass,
                                                    final String resourceName, final String extension, final boolean overwrite) throws IOException {
        final File temp = makeTestDataPath(graphClass, "resources");
        final File tempFile = new File(temp, resourceName + extension);

        // these checks are present mostly for windows compatibility where an outputstream created on a non-existent
        // file will cause an error.
        if(tempFile.exists() && !overwrite){
            // overwrite is disabled and file already exists -> reuse as-is
            return tempFile;
        }
        if(!tempFile.getParentFile().exists()){
            Files.createDirectories(tempFile.getParentFile().toPath());
        }
        // either the file does not exist or needs to be overwritten, drop it
        Files.deleteIfExists(tempFile.toPath());
        // create the new file
        Files.createFile(tempFile.toPath());

        // fill it with the desired contents
        try (final FileOutputStream outputStream = new FileOutputStream(tempFile)) {
            final byte[] buf = new byte[1024]; // use a buffer to boost the read/write speed
            int sz;
            try (final InputStream inputStream = resourceClass.getResourceAsStream(resourceName)) {
                while ((sz = inputStream.read(buf)) != -1) {
                    outputStream.write(buf, 0, sz);
                }
            }
        }
        return tempFile;
    }
Copies a file stored as part of a resource to the file system in the path returned from
{@link #makeTestDataPath} in a subdirectory called {@code temp/resources}.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java