FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
dcurl/java/org/dltcollab/Dcurl.java at develop · DLTcollab/dcurl · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DLTcollab
/
dcurl
Public
Notifications
You must be signed in to change notification settings
Fork
21
Star
40
Code
Issues
3
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
dcurl
/
java
/
org
/
dltcollab
/
Dcurl.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (37 loc) · 1.64 KB
Breadcrumbs
dcurl
/
java
/
org
/
dltcollab
/
Dcurl.java
Copy path
File metadata and controls
43 lines (37 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package
org
.
dltcollab
;
import
java
.
io
.*;
import
java
.
nio
.
file
.
Files
;
import
java
.
nio
.
file
.
StandardCopyOption
;
public
class
Dcurl
{
private
static
final
String
libraryName
=
"dcurl"
;
private
static
final
String
libraryPrefix
=
"lib"
;
private
static
final
String
librarySuffix
=
".so"
;
private
static
final
String
libraryFileName
=
libraryPrefix
+
libraryName
+
librarySuffix
;
public
void
loadLibraryFromJar
() {
final
File
temp
;
try
{
temp
=
File
.
createTempFile
(
libraryPrefix
+
libraryName
,
librarySuffix
);
if
(
temp
.
exists
() && !
temp
.
delete
()) {
throw
new
RuntimeException
(
"File: "
+
temp
.
getAbsolutePath
() +
" already exists and cannot be removed."
);
}
if
(!
temp
.
createNewFile
()) {
throw
new
RuntimeException
(
"File: "
+
temp
.
getAbsolutePath
() +
" could not be created."
);
}
if
(!
temp
.
exists
()) {
throw
new
RuntimeException
(
"File "
+
temp
.
getAbsolutePath
() +
" does not exist."
);
}
else
{
temp
.
deleteOnExit
();
}
// attempt to copy the library from the Jar file to the temp destination
try
(
final
InputStream
is
=
getClass
().
getClassLoader
().
getResourceAsStream
(
libraryFileName
)) {
if
(
is
==
null
) {
throw
new
RuntimeException
(
libraryFileName
+
" was not found inside JAR."
);
}
else
{
Files
.
copy
(
is
,
temp
.
toPath
(),
StandardCopyOption
.
REPLACE_EXISTING
);
}
}
System
.
load
(
temp
.
getAbsolutePath
());
}
catch
(
IOException
e
) {
}
}
}
Back
|
FazBrowse Home
|
New Git URL