से फ़ाइलों की प्रतिलिपि कैसे करें मेरे पास एक .jar है जिसमें दो .dll फ़ाइलें हैं जो यह निर्भर है। मैं जानना चाहूंगा कि मेरे लिए इन फ़ाइलों को .jar में से किसी उपयोगकर्ता टेम्पल फ़ोल्डर में रनटाइम पर कॉपी करने का कोई तरीका है या नहीं।वर्तमान में चल रहे जार
public String tempDir = System.getProperty("java.io.tmpdir");
public String workingDir = dllInstall.class.getProtectionDomain().getCodeSource().getLocation().getPath();
public boolean installDLL() throws UnsupportedEncodingException {
try {
String decodedPath = URLDecoder.decode(workingDir, "UTF-8");
InputStream fileInStream = null;
OutputStream fileOutStream = null;
File fileIn = new File(decodedPath + "\\loadAtRuntime.dll");
File fileOut = new File(tempDir + "loadAtRuntime.dll");
fileInStream = new FileInputStream(fileIn);
fileOutStream = new FileOutputStream(fileOut);
byte[] bufferJNI = new byte[8192000013370000];
int lengthFileIn;
while ((lengthFileIn = fileInStream.read(bufferJNI)) > 0) {
fileOutStream.write(bufferJNI, 0, lengthFileIn);
}
//close all steams
} catch (IOException e) {
e.printStackTrace();
return false;
} catch (UnsupportedEncodingException e) {
System.out.println(e);
return false;
}
मेरा मुख्य समस्या रनटाइम पर जार से बाहर .dll फ़ाइलें हो रही है: यहाँ वर्तमान कोड है कि मैं (सिर्फ एक .dll लोड करने के लिए संपादित प्रश्न के आकार को कम करने के लिए) है। .jar के भीतर से पथ को पुनर्प्राप्त करने का कोई भी तरीका सहायक होगा।
अग्रिम धन्यवाद।
क्या आप आसपास के डीडी फाइलों के पथ प्राप्त करना चाहते हैं – user217895
हां बस मैं फाइलों पर जा सकता हूं और उन्हें कॉपी कर सकता हूं। मुझे बस वर्ग पथ की जरूरत है। मैं पहले से ही फाइलों की प्रतिलिपि बनाने के बारे में जानता हूं। उदाहरण कोड के लिए – DeanMWake