Se connecter / S'enregistrer

Résolu [java] copier deux fichier dans deux dossier de la clée USB

Solutions (4)
Tags :
  • Cursor
  • Java
  • Io
  • Crypter
  • Programmation
, Maître Yoda |
bonjours a tous :ange: 
Je vous pris de m'excuser car le titre de mon post ne semble pas très explicite mais je ne s'avais pas comment le formuler autrement.

Mon soucie étant que j'ai repris le travail d'un ancien stagière qui permetter de crypter une clée USB, et durant l'installation il y a 2 fichier (const.ini et licence.ini) qui se colle dans la racine de ma clée USB, mais je voudrais que ses fichiers se colle dans deux dossier en racine de ma clée USB, un dossier "English" et l'autre "Francais".
Voici le code :


  1. package usbnumecrypt;
  2.  
  3. import java.awt.Cursor;
  4. import java.io.BufferedReader;
  5. import java.io.FileNotFoundException;
  6. import java.io.UnsupportedEncodingException;
  7. import java.io.File;
  8. import java.io.FileInputStream;
  9. import java.io.FileOutputStream;
  10. import java.nio.channels.FileChannel;
  11. import java.util.ArrayList;
  12. import java.util.logging.Level;
  13. import java.util.logging.Logger;
  14.  
  15. import java.io.IOException;
  16. import java.io.InputStreamReader;
  17. import javax.crypto.spec.SecretKeySpec;
  18. import javax.swing.JFileChooser;
  19. import usbnumecrypt.USB.*;
  20.  
  21. /**
  22. *
  23. * @author pippin
  24. */
  25. public class Crypter extends javax.swing.JFrame {
  26.  
  27. private ArrayList<USBKey> cles;
  28. private ArrayList<File> keyRoot;
  29. private File directory,tempDir;
  30. private int vendorID, productID;
  31. private SecretKeySpec key1;
  32. private DesEncrypter cipher;
  33. private boolean creating;
  34.  
  35. /** Creates new form Crypter */
  36. public Crypter(int vendorID,int productID, File directory) {
  37. creating=true;
  38. this.setCursor(Cursor.WAIT_CURSOR);
  39.  
  40.  
  41. this.vendorID = vendorID;this.directory=directory;
  42. this.productID = productID;
  43. File reg;
  44. FileOutputStream stream=null;
  45. try {
  46.  
  47. String k1="4??%????";
  48.  
  49. key1= new SecretKeySpec(k1.getBytes("UTF8"),"DES");
  50.  
  51. cipher= new DesEncrypter(key1);
  52.  
  53.  
  54.  
  55. actualiser();
  56. initComponents();
  57. java.awt.Dimension screenSize = java.awt.Toolkit. getDefaultToolkit (). getScreenSize ();
  58. this.setBounds(screenSize.width/2, screenSize.height/2-this.getHeight()/2, this.getWidth(), this.getHeight());
  59.  
  60. jDialog1.setBounds(screenSize.width/2-this.getWidth(), screenSize.height/2-this.getHeight()/2, jDialog1.getWidth(), jDialog1.getHeight());
  61. validRootList.setListData(keyRoot.toArray());
  62.  
  63.  
  64. String str1 ="";
  65. for (int i = 0; i != key1.getEncoded().length; i++) {
  66. str1+=(int)key1.getEncoded()[i];
  67. }
  68.  
  69. jTextArea1.setText( " cliquer sur \"Crypter\" pour lancer le processus\n\n " +
  70. "masque VendorID=0x"+Integer.toHexString(vendorID)+"" +
  71. "\n masque productID=0x"+Integer.toHexString(productID)+
  72. "\n DES key : "+str1+
  73. "\n\n les fichiers d'installation se trouvent dans : \n "+directory.toString());
  74.  
  75.  
  76. } catch (UnsupportedEncodingException ex) {
  77. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  78. } finally {
  79. try {
  80. if(stream!=null)
  81. stream.close();
  82. } catch (IOException ex) {
  83. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  84. }finally{
  85. this.setCursor(Cursor.DEFAULT_CURSOR);
  86. }
  87. }
  88.  
  89. }
  90.  
  91. /** This method is called from within the constructor to
  92. * initialize the form.
  93. * WARNING: Do NOT modify this code. The content of this method is
  94. * always regenerated by the Form Editor.
  95. */
  96. @SuppressWarnings("unchecked")
  97. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  98. private void initComponents() {
  99.  
  100. fileChooser = new javax.swing.JFileChooser();
  101. jDialog1 = new javax.swing.JDialog();
  102. fileField = new javax.swing.JTextField();
  103. jLabel1 = new javax.swing.JLabel();
  104. parcourir = new javax.swing.JButton();
  105. vidField = new javax.swing.JTextField();
  106. jLabel2 = new javax.swing.JLabel();
  107. pidField = new javax.swing.JTextField();
  108. jLabel3 = new javax.swing.JLabel();
  109. valider = new javax.swing.JButton();
  110. cancel = new javax.swing.JButton();
  111. jScrollPane1 = new javax.swing.JScrollPane();
  112. validRootList = new javax.swing.JList();
  113. crypter = new javax.swing.JButton();
  114. quitter = new javax.swing.JButton();
  115. jScrollPane2 = new javax.swing.JScrollPane();
  116. jTextArea1 = new javax.swing.JTextArea();
  117. refresh = new javax.swing.JButton();
  118. modif = new javax.swing.JButton();
  119.  
  120. fileChooser.setAcceptAllFileFilterUsed(false);
  121. fileChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
  122.  
  123. jDialog1.setMinimumSize(new java.awt.Dimension(430, 260));
  124. jDialog1.setResizable(false);
  125.  
  126. jLabel1.setText("Chemin des fichiers d'install :");
  127.  
  128. parcourir.setText("Parcourir");
  129. parcourir.addActionListener(new java.awt.event.ActionListener() {
  130. public void actionPerformed(java.awt.event.ActionEvent evt) {
  131. parcourirActionPerformed(evt);
  132. }
  133. });
  134.  
  135. jLabel2.setText("VendorID (hexa 4 digit)");
  136.  
  137. jLabel3.setText("ProductID (hexa 4 digit)");
  138.  
  139. valider.setText("Valider");
  140. valider.addActionListener(new java.awt.event.ActionListener() {
  141. public void actionPerformed(java.awt.event.ActionEvent evt) {
  142. validerActionPerformed(evt);
  143. }
  144. });
  145.  
  146. cancel.setText("Annuler");
  147. cancel.addActionListener(new java.awt.event.ActionListener() {
  148. public void actionPerformed(java.awt.event.ActionEvent evt) {
  149. cancelActionPerformed(evt);
  150. }
  151. });
  152.  
  153. javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
  154. jDialog1.getContentPane().setLayout(jDialog1Layout);
  155. jDialog1Layout.setHorizontalGroup(
  156. jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  157. .addGroup(jDialog1Layout.createSequentialGroup()
  158. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  159. .addGroup(jDialog1Layout.createSequentialGroup()
  160. .addGap(33, 33, 33)
  161. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  162. .addComponent(vidField)
  163. .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  164. .addGap(10, 10, 10)
  165. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  166. .addGroup(jDialog1Layout.createSequentialGroup()
  167. .addGap(112, 112, 112)
  168. .addComponent(cancel))
  169. .addGroup(jDialog1Layout.createSequentialGroup()
  170. .addGap(89, 89, 89)
  171. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  172. .addComponent(pidField, javax.swing.GroupLayout.Alignment.TRAILING)
  173. .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  174. .addGap(23, 23, 23))
  175. .addGroup(jDialog1Layout.createSequentialGroup()
  176. .addContainerGap()
  177. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  178. .addComponent(valider)
  179. .addComponent(jLabel1))
  180. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  181. .addComponent(fileField, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
  182. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  183. .addComponent(parcourir)))
  184. .addContainerGap(18, Short.MAX_VALUE))
  185. );
  186. jDialog1Layout.setVerticalGroup(
  187. jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  188. .addGroup(jDialog1Layout.createSequentialGroup()
  189. .addGap(22, 22, 22)
  190. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  191. .addComponent(jLabel1)
  192. .addComponent(fileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  193. .addComponent(parcourir))
  194. .addGap(42, 42, 42)
  195. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  196. .addComponent(vidField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  197. .addComponent(pidField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  198. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  199. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  200. .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
  201. .addComponent(jLabel2))
  202. .addGap(48, 48, 48)
  203. .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  204. .addComponent(valider)
  205. .addComponent(cancel))
  206. .addContainerGap(25, Short.MAX_VALUE))
  207. );
  208.  
  209. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  210. setTitle("Crypteur de clé USB");
  211.  
  212. jScrollPane1.setViewportView(validRootList);
  213.  
  214. crypter.setText("Crypter");
  215. crypter.addActionListener(new java.awt.event.ActionListener() {
  216. public void actionPerformed(java.awt.event.ActionEvent evt) {
  217. crypterActionPerformed(evt);
  218. }
  219. });
  220.  
  221. quitter.setText("Quitter");
  222. quitter.addActionListener(new java.awt.event.ActionListener() {
  223. public void actionPerformed(java.awt.event.ActionEvent evt) {
  224. quitterActionPerformed(evt);
  225. }
  226. });
  227.  
  228. jTextArea1.setBackground(new java.awt.Color(204, 204, 204));
  229. jTextArea1.setColumns(20);
  230. jTextArea1.setEditable(false);
  231. jTextArea1.setRows(5);
  232. jTextArea1.setText( "Les clé suivantes vont être cryptées lorsque \n vous aurez cliqué sur le bouton \"Crypter\"\n\n masque VendorID=0x"+Integer.toHexString(vendorID)+"\n masque productID=0x"+Integer.toHexString(productID));
  233. jTextArea1.setBorder(null);
  234. jScrollPane2.setViewportView(jTextArea1);
  235.  
  236. refresh.setText("Refresh");
  237. refresh.addActionListener(new java.awt.event.ActionListener() {
  238. public void actionPerformed(java.awt.event.ActionEvent evt) {
  239. refreshActionPerformed(evt);
  240. }
  241. });
  242.  
  243. modif.setText("Modif");
  244. modif.addActionListener(new java.awt.event.ActionListener() {
  245. public void actionPerformed(java.awt.event.ActionEvent evt) {
  246. modifActionPerformed(evt);
  247. }
  248. });
  249.  
  250. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  251. getContentPane().setLayout(layout);
  252. layout.setHorizontalGroup(
  253. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  254. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  255. .addContainerGap()
  256. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  257. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
  258. .addGroup(layout.createSequentialGroup()
  259. .addComponent(refresh)
  260. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  261. .addComponent(modif)))
  262. .addGap(64, 64, 64)
  263. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  264. .addGroup(layout.createSequentialGroup()
  265. .addComponent(crypter)
  266. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)
  267. .addComponent(quitter)
  268. .addGap(32, 32, 32))
  269. .addGroup(layout.createSequentialGroup()
  270. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
  271. .addContainerGap())))
  272. );
  273. layout.setVerticalGroup(
  274. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  275. .addGroup(layout.createSequentialGroup()
  276. .addContainerGap()
  277. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  278. .addGroup(layout.createSequentialGroup()
  279. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  280. .addComponent(refresh)
  281. .addComponent(modif))
  282. .addGap(13, 13, 13)
  283. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE))
  284. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  285. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
  286. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
  287. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  288. .addComponent(crypter)
  289. .addComponent(quitter))))
  290. .addContainerGap())
  291. );
  292.  
  293. pack();
  294. }// </editor-fold>
  295.  
  296. private void quitterActionPerformed(java.awt.event.ActionEvent evt) {
  297. System.exit(0);
  298. }
  299.  
  300. private void crypterActionPerformed(java.awt.event.ActionEvent evt) {
  301. processCrypt();
  302. }
  303.  
  304. private void refreshActionPerformed(java.awt.event.ActionEvent evt) {
  305. actualiser();
  306. }
  307.  
  308. private void modifActionPerformed(java.awt.event.ActionEvent evt) {
  309. fileField.setText(directory.toString());
  310.  
  311. vidField.setText(""+Integer.toHexString(vendorID));
  312. pidField.setText(""+Integer.toHexString(productID));
  313. jDialog1.setVisible(true);
  314. }
  315.  
  316. private void parcourirActionPerformed(java.awt.event.ActionEvent evt) {
  317. if(fileChooser.showOpenDialog(this)==JFileChooser.APPROVE_OPTION){
  318. tempDir = fileChooser.getCurrentDirectory();
  319. fileField.setText(tempDir.toString());
  320. }
  321. }
  322.  
  323. private void validerActionPerformed(java.awt.event.ActionEvent evt) {
  324. FileOutputStream out = null;
  325. try {
  326. this.setCursor(Cursor.WAIT_CURSOR);
  327. directory = tempDir;
  328. vendorID = Integer.parseInt(vidField.getText(), 16);
  329. productID = Integer.parseInt(pidField.getText(), 16);
  330. File keys = new File("const.ini");
  331. keys.delete();
  332. out = new FileOutputStream(keys);
  333. out.write(vendorID);out.write('&');out.write(productID);out.write('\n');
  334. out.write(directory.getPath().getBytes("UTF8"));
  335.  
  336.  
  337.  
  338. String str1 = "";
  339. for (int i = 0; i != key1.getEncoded().length; i++) {
  340. str1 += (int) key1.getEncoded()[i];
  341. }
  342.  
  343. jTextArea1.setText(" cliquer sur \"Crypter\" pour lancer le processus\n\n " + "masque VendorID=0x" + Integer.toHexString(vendorID) + "" + "\n masque productID=0x" + Integer.toHexString(productID) + "\n DES key : " + str1 + "\n\n les fichiers d'installation se trouvent dans : \n " + directory.toString());
  344.  
  345. jDialog1.setVisible(false);
  346. } catch (FileNotFoundException ex) {
  347. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  348. } catch (IOException ex) {
  349. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  350. } finally {
  351. try {
  352. out.close();
  353.  
  354. } catch (IOException ex) {
  355. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  356. }finally{
  357. this.setCursor(Cursor.DEFAULT_CURSOR);
  358. }
  359. }
  360. }
  361.  
  362. private void cancelActionPerformed(java.awt.event.ActionEvent evt) {
  363. jDialog1.setVisible(false);
  364. }
  365.  
  366.  
  367.  
  368. private void actualiser(){
  369. if(!creating)
  370. this.setCursor(Cursor.WAIT_CURSOR);
  371. File report = new File("report");
  372. try {
  373. cles=new ArrayList<USBKey>();
  374. keyRoot = new ArrayList<File>();
  375. Runtime runtime = Runtime.getRuntime();
  376.  
  377.  
  378. String[] command = {"cmd.exe", "/C", "usbdeview.exe /stext \"" + report.getName() + "\""};
  379. Process process = runtime.exec(command);
  380. try {
  381. Thread.sleep(1000);
  382. } catch (InterruptedException ex) {
  383. System.out.println("cagade de thread");
  384. }
  385. ArrayList<USBKey> list = USButil.getConnectedUSBKeyList(report);
  386. if (list != null) {
  387. for (int i = 0; i != list.size(); i++) {
  388. if (list.get(i).getVendorID() == vendorID && list.get(i).getProductID() == productID) {
  389. keyRoot.add(list.get(i).getAddress());
  390. cles.add(list.get(i));
  391. }
  392. }
  393. } else {
  394. System.out.println("Ca a foiré");
  395. }
  396. report.delete();
  397. } catch (IOException ex) {
  398. if(report.exists()){
  399. report.delete();
  400. }
  401. ErrGlobale err = new ErrGlobale("Echec du refresh");
  402. err.setVisible(true);
  403. }finally{
  404. if(!creating)
  405. this.setCursor(Cursor.DEFAULT_CURSOR);
  406. }
  407. }
  408.  
  409. private void processCrypt() {
  410. FileOutputStream stream = null;
  411.  
  412. BufferedReader reader=null;
  413. this.setCursor(Cursor.WAIT_CURSOR);
  414. try {
  415. for(int i=0;i!=cles.size();i++){
  416.  
  417. byte[] b;
  418. USBKey usb = cles.get(i);
  419. System.out.println(usb.getSerialNumber());
  420. b=usb.getSerialNumber().getBytes("UTF8");
  421. String str = new String(b,"UTF8");
  422. System.out.println(str);
  423. for(int j=0;j!=b.length;j++){
  424. System.out.print((char)b[j]+" ");
  425. }
  426. File ini = new File(usb.getAddress().getAbsolutePath().concat("const.ini"));
  427. File ini2= new File(usb.getAddress().getAbsolutePath().concat("licence.ini"));
  428. stream = new FileOutputStream(ini);
  429. //remplissage du fichier const.ini
  430. stream.write(Integer.toHexString(vendorID).getBytes());
  431. stream.write((int)'&');
  432. stream.write(Integer.toHexString(productID).getBytes());
  433.  
  434. //remplissage du fichier licence.ini
  435. stream = new FileOutputStream(ini2);
  436.  
  437. stream.write(getCleCrypte(usb.getSerialNumber()));
  438. stream.close();
  439.  
  440.  
  441.  
  442. System.out.println(str);
  443. File copy= new File(usb.getAddress().getAbsolutePath()+"install"+"English"+"Francais");
  444. copyFileTree(directory, copy);
  445.  
  446. }
  447.  
  448. } catch (FileNotFoundException ex) {
  449.  
  450. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  451.  
  452. } catch (IOException ex) {
  453.  
  454. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  455.  
  456. } finally {
  457.  
  458. try {
  459.  
  460. stream.close();
  461.  
  462. } catch (IOException ex) {
  463.  
  464. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  465.  
  466. }
  467. }
  468. this.setCursor(Cursor.DEFAULT_CURSOR);
  469. }
  470.  
  471.  
  472.  
  473. private byte[] getCleCrypte(String serial){
  474.  
  475. return cipher.encrypt(serial);
  476. }
  477.  
  478.  
  479.  
  480. /**
  481. * copie l'arborescence des fichiers du source vers la destination
  482. */
  483. private static boolean copyFileTree(File source, File dest){
  484. boolean result=true;
  485. FileChannel in = null; // canal d'entrée
  486. FileChannel out = null; // canal de sortie
  487.  
  488. try {
  489. // Init
  490. if(source.isDirectory()){
  491. File[] files = source.listFiles();
  492. dest.mkdir();
  493. File dest2;
  494. for(int i=0;i!=files.length;i++){
  495. dest2= new File(dest.getAbsolutePath()+"/"+files[i].getName());
  496. result = result && copyFileTree(files[i],dest2);
  497. }
  498. }else{
  499. in = new FileInputStream(source).getChannel();
  500. out = new FileOutputStream(dest).getChannel();
  501.  
  502. // Copie depuis le in vers le out
  503. in.transferTo(0, in.size(), out);
  504. }
  505. } catch (Exception e) {
  506. e.printStackTrace(); // n'importe quelle exception
  507. result= false;
  508. } finally { // finalement on ferme
  509. if(in != null) {
  510. try {
  511. in.close();
  512. } catch (IOException e) {}
  513. }
  514. if(out != null) {
  515. try {
  516. out.close();
  517. } catch (IOException e) {}
  518. }
  519. return result;
  520.  
  521. }
  522. }
  523.  
  524. /**
  525. * @param args the command line arguments
  526. */
  527. public static void main(String args[]) {
  528. java.awt.EventQueue.invokeLater(new Runnable() {
  529. public void run() {
  530.  
  531. FileInputStream stream=null;
  532. InputStreamReader in=null;
  533. BufferedReader reader=null;
  534. try {
  535.  
  536. int vendorID;
  537. int productID;
  538.  
  539. File keys = new File("const.ini");
  540. stream = new FileInputStream(keys);
  541. in= new InputStreamReader(stream);
  542. reader= new BufferedReader(in);
  543. String keyLine= reader.readLine();
  544.  
  545. String[] keySplit = keyLine.split("&");
  546. vendorID=Integer.parseInt(keySplit[0],16);
  547. productID=Integer.parseInt(keySplit[1],16);
  548. String path = reader.readLine();
  549. File installFilesPath= new File(path);
  550. new Crypter(vendorID, productID, installFilesPath).setVisible(true);
  551.  
  552. } catch (Exception ex) {
  553. ErrGlobale err = new ErrGlobale("le fichier const.ini a chié dans la colle");
  554. err.setVisible(true);
  555. } finally {
  556. try {
  557. if(stream!=null)
  558. stream.close();
  559. if(in!=null)
  560. in.close();
  561. if(reader!=null)
  562. reader.close();
  563.  
  564. } catch (IOException ex) {
  565. Logger.getLogger(Crypter.class.getName()).log(Level.SEVERE, null, ex);
  566. }
  567. }
  568. }
  569. });
  570.  
  571.  
  572. //
  573. }
  574.  
  575. // Variables declaration - do not modify
  576. private javax.swing.JButton cancel;
  577. private javax.swing.JButton crypter;
  578. private javax.swing.JFileChooser fileChooser;
  579. private javax.swing.JTextField fileField;
  580. private javax.swing.JDialog jDialog1;
  581. private javax.swing.JLabel jLabel1;
  582. private javax.swing.JLabel jLabel2;
  583. private javax.swing.JLabel jLabel3;
  584. private javax.swing.JScrollPane jScrollPane1;
  585. private javax.swing.JScrollPane jScrollPane2;
  586. private javax.swing.JTextArea jTextArea1;
  587. private javax.swing.JButton modif;
  588. private javax.swing.JButton parcourir;
  589. private javax.swing.JTextField pidField;
  590. private javax.swing.JButton quitter;
  591. private javax.swing.JButton refresh;
  592. private javax.swing.JList validRootList;
  593. private javax.swing.JButton valider;
  594. private javax.swing.JTextField vidField;
  595. // End of variables declaration
  596.  
  597. }


quelqun pourrais me guider dans se que je devrais changer pour copier ses deux fichier dans à l'endroit voulu?
J'utilise le logiciel Netbeans.

Je vous remercie d'avance (et ne vous demande en aucun cas de faire le travail à ma place mais je souhaiterais juste être guider )
Contenus similaires
Meilleure solution
partage
|
  1. File ini = new File(usb.getAddress().getAbsolutePath().concat("DOSSIER/const.ini" ));
  2. File ini2= new File(usb.getAddress().getAbsolutePath().concat("DOSSIER/licence.ini" ));


Et

  1. File keys = new File("DOSSIER/const.ini" );



Je n'ai pas analysé tout le code, la flemme et en plus c'est un gros bloc pas très propre... Mais un truc du genre devrait suffire, enfin dans l'idée ;) 
  • Commenter cette solution |
Score
0
òh
òi
|
danydan01 a dit :
Encore merci!!!


You're welcome
  • Commenter cette réponse |
Score
0
òh
òi
, Maître Yoda |
Merci Redtux pour ton aide cela fonctionne nikel :sol: 
La deuxième partie n'est pas nécessaire.

1.File keys = new File("DOSSIER/const.ini" );

Encore merci!!!
  • Commenter cette réponse |
Score
0
òh
òi
, Maître Yoda |
Meilleure réponse sélectionnée par danydan01.
  • Commenter cette réponse |

Ce n'est pas ce que vous cherchiez ?

Tom's guide dans le monde
  • Allemagne
  • Italie
  • Irlande
  • Royaume Uni
  • Etats Unis
Suivre Tom's Guide
Inscrivez-vous à la Newsletter
  • ajouter à twitter
  • ajouter à facebook
  • ajouter un flux RSS