diff --git a/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java b/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java index ae8b3113..7c76dada 100644 --- a/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java +++ b/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java @@ -17,6 +17,7 @@ import java.io.*; import java.net.ServerSocket; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; @@ -96,8 +97,7 @@ public static void startEmbeddedCassandra(String yamlFile, String tmpDir, long t } rmdir(tmpDir); - copy(yamlFile, tmpDir); - File file = new File(tmpDir + yamlFile); + File file = copy(yamlFile, tmpDir).toFile(); readAndAdaptYaml(file); startEmbeddedCassandra(file, tmpDir, timeout); } @@ -285,11 +285,13 @@ private static void rmdir(String dir) { * @param directory * @throws IOException */ - private static void copy(String resource, String directory) throws IOException { + private static Path copy(String resource, String directory) throws IOException { mkdir(directory); String fileName = resource.substring(resource.lastIndexOf("/") + 1); InputStream from = EmbeddedCassandraServerHelper.class.getResourceAsStream(resource); - Files.copy(from, Paths.get(directory + System.getProperty("file.separator") + fileName)); + Path copyName = Paths.get(directory, fileName); + Files.copy(from, copyName); + return copyName; } /**