[Java]Accès refusé FileInputStream
Résolu/Fermé
A voir également:
- Java.io.filenotfoundexception (accès refusé)
- Accès refusé - Guide
- Acces rapide - Guide
- Comment supprimer un fichier qui refuse d'être supprimé - Guide
- Trousseau d'accès iphone - Guide
- Free flex refusé ✓ - Forum Free mobile
5 réponses
Ben la comme ça, j'aurais tendance à dire qu'il manque le nom du fichier à la lecture. On dirait que tu essayes de lire "C:\Users\Edwin\cryp" au lieu de "C:\Users\Edwin\cryp\xxx.yyy" (ta variable ent que tu passes en paramètre).
ublic static void Encrypt(String ent , String sort){ @SuppressWarnings("unused") int n = 0; double w = 0; String fin = (""); long d = 0; System.out.println("test 1"); int r = 0; char c = 0; String temp = (""); String tamp = (""); ArrayList stock = new ArrayList(); ArrayList bin = new ArrayList(); int h = 0; long u = 0; String gus; gus = ("C:\\Users\\Edwin\\crypt\\"+ent); BufferedInputStream bsd = null; ObjectOutputStream bod = null; try { bsd = new BufferedInputStream(new FileInputStream(new File(gus))); bod = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(new File("C:\\Users\\Edwin\\crypt\\"+sort+".txt")))); System.out.println("test 2"); byte[] buf = new byte[16]; while((n = bsd.read(buf)) >= 0){ System.out.println("test 3"); for(int y = 0; y <= 15; y++){ r = buf[y]; if(r != 0){ for(byte bit : buf) c = (char)bit; if(r < 100){ u = (u * 100) + r; bin.add(false); //si le nombre est plus petit, on ajoute false } else{ u = (u*1000) + r; bin.add(true); //donc si il est plus grad, ce sera true } System.out.println("alitération:"+y); } else{ System.out.println("erreur"); y = 16; n = -1; } tamp = (""+tamp+u); u = 0; } } for( int i = 0; i < tamp.length(); i += 17 ){ int j = 0; j = i + 17; long g = 0; if((j)>tamp.length() ){ j = tamp.length() ; } temp = tamp.substring(i,j); System.out.println("temp:"+temp); System.out.println("i:"+i); System.out.println("j:"+j); for(int f = 1; f <= 18; f++){ String y = (""); int a = 0; int p = 0; if(temp.length()<=f) { y = temp.substring(temp.length()-1,temp.length()); a = y.charAt(0); System.out.println("y:"+y); System.out.println("a:"+a); switch(a){ case 49: p = 1; break; case 50: p = 2; break; case 51: p = 3; break; case 52: p = 4; break; case 53: p = 5; break; case 54: p = 6; break; case 55: p = 7; break; case 56: p = 8; break; case 57: p = 9; break; case 48: p = 0; break; default: p = 0; } System.out.println("p:"+p); g = (g * 10) + p; } else{ y = temp.substring(f-1,f); a = y.charAt(0); System.out.println("y:"+y); System.out.println("a:"+a); switch(a){ case 49: p = 1; break; case 50: p = 2; break; case 51: p = 3; break; case 52: p = 4; break; case 53: p = 5; break; case 54: p = 6; break; case 55: p = 7; break; case 56: p = 8; break; case 57: p = 9; break; case 48: p = 0; break; default: p = 0; } System.out.println("p:"+p); g = (g * 10) + p; } System.out.println("g:"+g); } System.out.println("g:"+g); w = (Math.pow(g, 1.0/69.0)); System.out.println("w"+w); stock.add(w); g = 0; if(j == tamp.length()){ i = tamp.length() + 15; } } bod.writeObject(stock); bod.writeObject(bin); System.out.println("crypted!"); } catch (FileNotFoundException e) { System.out.println("Fichier introuvable"); e.printStackTrace(); } catch (IOException e){ System.out.println("Erreur dans la lecture."); e.printStackTrace(); } finally{ try{ if(bsd != null ) bsd.close(); if(bod != null) bod.close(); } catch (IOException e){ System.out.println("Erreur dans la fermeture des flux."); } } }
Ce code est un vrai foutoir je sais, l'organisation c'est pas encore ça ches moi x)
c'est possible, je vais essayer de voir si en modifiant les paramètres et en mettant directement le fichier a lire
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question