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
| public void copyJars(){
//à verifier dans le cas ou le projet ne se trouve pas dans le workspace
Bundle myBundle = Platform.getBundle(Activator.PLUGIN_ID);
String s=myBundle.getLocation().substring(16,myBundle.getLocation().toString().length()-1);
String d=Platform.getLocation()+"//"+uno.getCombo().getText();
String sProtocol=MetaData.mabase.getMacx().getMonUrl().getSous_protocol();
if(sProtocol.equals("mysql")){
s+=myBundle.getEntry("//lib//mysql-connector-java-5.1.6-bin.jar").getFile();
d+="//lib//mysql-connector-java-5.1.6-bin.jar";
}else if(sProtocol.equals("oracle8p")){
s+=myBundle.getEntry("//lib//ojdbc14.jar").getFile();
d+="//lib//ojdbc14.jar";
}else{//à completer
s+=myBundle.getEntry("//lib//ojdbc14.jar").getFile();
d+="//lib//ojdbc14.jar";
}
File source = new File(s);
File dest = new File(d);
if (dest.exists())
return;
try{
File f=new File(Platform.getLocation()+"//"+uno.getCombo().getText()+"//lib");
f.mkdirs();
java.io.FileInputStream sourceFile = new java.io.FileInputStream(source);
try{
java.io.FileOutputStream destinationFile = null;
try{
destinationFile = new FileOutputStream(dest);
byte buffer[] = new byte[512 * 1024];
int nbLecture;
while ((nbLecture = sourceFile.read(buffer)) != -1){
destinationFile.write(buffer, 0, nbLecture);
}
} finally {
destinationFile.close();
}
} finally {
sourceFile.close();
}
} catch (IOException e){
e.printStackTrace();
}
} |
Partager