1
1
package util .file_managers ;
2
2
3
3
import java .io .*;
4
- import java .net .MalformedURLException ;
5
4
import java .net .URL ;
6
- import java .net .URLConnection ;
7
5
import java .nio .channels .Channels ;
8
- import java .nio .channels .FileChannel ;
9
6
import java .nio .channels .ReadableByteChannel ;
10
7
import java .nio .file .Files ;
11
8
import java .nio .file .Path ;
@@ -35,7 +32,7 @@ public static InputStream loadFile(final String relativeFilePath) {
35
32
saveFileFromGitHubToDataDirectory (relativeFilePath );
36
33
return loadFileFromDataDir (relativeFilePath );
37
34
38
- //
35
+
39
36
// InputStream jarInputStream = loadFileFromJar(relativeFilePath);
40
37
//
41
38
// if (jarInputStream != null) {
@@ -48,7 +45,8 @@ public static InputStream loadFile(final String relativeFilePath) {
48
45
}
49
46
50
47
private static InputStream loadFileFromJar (final String relativeFilePath ) {
51
- String jarFilePath = "/" + relativeFilePath ;
48
+ String jarFilePath = "/resources/" + relativeFilePath ;
49
+ System .out .println (jarFilePath );
52
50
return ResourceManager .class .getResourceAsStream (jarFilePath );
53
51
}
54
52
@@ -85,7 +83,12 @@ private static void saveFileFromGitHubToDataDirectory(final String relativeFileP
85
83
86
84
ReadableByteChannel readableByteChannel = Channels .newChannel (url .openStream ());
87
85
88
- FileOutputStream fileOutputStream = new FileOutputStream (Paths .get (DIRECTORY , relativeFilePath ).toFile ());
86
+ File outputFile = Paths .get (DIRECTORY , relativeFilePath ).toFile ();
87
+
88
+ outputFile .getParentFile ().mkdirs ();
89
+ outputFile .createNewFile ();
90
+
91
+ FileOutputStream fileOutputStream = new FileOutputStream (outputFile );
89
92
fileOutputStream .getChannel ().transferFrom (readableByteChannel , 0 , Long .MAX_VALUE );
90
93
} catch (IOException e ) {
91
94
e .printStackTrace ();
0 commit comments