Je ne sais pas ce qui ne va pas avec mon code mais dès que je fais un retour avec un tableau ca ne marche plus...
Voila mon code:
Ya un problème avec juste les lignes en gras... Svp si qqn peut m'aider je suis coincée sur ce truc
package test7;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.jfree.ui.RefineryUtilities;
public class Test7 {
public static int[] main(String[] args){
int T[] = new int[50];
try {
int x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 0, x8 = 0, x9 = 0, x10 = 0, x11 = 0, x12 = 0, x13 = 0, x14 = 0, x15 = 0, x16 = 0, x17 = 0, x18 = 0, x19 = 0, x20 = 0, x21 = 0, x22 = 0, x23 = 0;
int A = 555, S = 0;
String ligne = new String(" " );
String date = new String(" " );
//System.out.println("Veuillez saisir le chemin du fichier log" );
// String chemin = saisie_string();
// File f = new File (chemin);
File f = new File(
"C:\\Documents and Settings\\Petite f�e\\Bureau\\Charging.log" );
InputStream ips = new FileInputStream(f);
InputStreamReader ipsr = new InputStreamReader(ips);
BufferedReader br = new BufferedReader(ipsr);
if (f.exists()) {
System.out
.println("Veuillez saisir la date � partir de laquelle vous souhaitez avoir les erreurs g�n�r�es en respectant le format YYYY-MM-DD " );
date = saisie_string();
System.out.println(date);
while ((ligne = br.readLine()) != null) {
if (ligne.startsWith(date)) {
String[] table = ligne.split("\\s" );
for (int i = 0; i < table.length; i++)
if (table[i].compareTo("Description=Success" ) == 0) {
S++;
A= Integer.parseInt(table[i+1].substring(5, table[i+1].length()));
System.out.println(A);
switch (A) {
case 0:
x1++;
break;
case 010:
x2++;
break;
// Bad parameter
case 011:
x3++;
break;
// Timeout pool de connexion client
// RTCG
case 012:
x4++;
break;
// Timeout RTCG : Waiting for data
case 013:
x5++;
break;
// Database error
case 999:
x6++;
break;
//System Error
case 100:
x7++;
break;
// Account inactive/expired.
case 101:
x8++;
break;
// Account locked
case 102:
x9++;
break;
// Account balance is less than the
// requested amount to debit or
// reserve.
case 103:
x10++;
break;
// Subscriber unknown
case 104:
x11++;
break;
// Account unknown
case 105:
x12++;
break;
// Could not charge chargedParty.
// Origin or Destination does not
// exist.
case 106:
x13++;
break;
// Could not determine tariff plan
case 107:
x14++;
break;
// Account unavailable
case 108:
x15++;
break;
// Subscriber is Blacklisted
case 109:
x16++;
break;
// Reservation Error
case 110:
x17++;
break;
// Rating error
case 200:
x18++;
break;
// Missing parameter.
case 201:
x19++;
break;
// Invalid format of parameter.
case 202:
x20++;
break;
// Unknown chargeSessionId
case 203:
x21++;
break;
// Invalid operation, post-paid user.
// Try Rate and Debit instead
case 300:
x22++;
break;
// System temporarily unavailable
case 301:
x23++;
break;
// System error.
}
}
}
}
}
System.out.println("Le nombre de lignes est :" );
System.out.println(S);
if (x1!=0)
{
System.out.println(x1);
System.out.println("Le taux de succ�s est :" );
System.out.println((100 * x1) / S);
}
if (x2!=0)
{
System.out.println(x2);
System.out.println("Le taux de l'erreur Bad parameter est :" );
System.out.println((100 * x2) / S);
}
if (x3!=0)
{
System.out.println(x3);
System.out.println("Le taux de l'erreur Timeout pool de connexion client RTCG est :" );
System.out.println((100 * x3) / S);
}
if (x4!=0)
{
System.out.println(x4);
System.out.println("Le taux de l'erreur Timeout RTCG : Waiting for data est :" );
System.out.println((100 * x4) / S);
}
if (x5!=0)
{
System.out.println(x5);
System.out.println("Le taux de l'erreur Database error est :" );
System.out.println((100 * x5) / S);
}
if (x6!=0)
{
System.out.println(x6);
System.out.println("Le taux de l'erreur System Error est :" );
System.out.println((100 * x6) / S);
}
if (x7!=0)
{
System.out.println(x7);
System.out.println("Le taux de l'erreur Account inactive/expired est :" );
System.out.println((100 * x7) / S);
}
if (x8!=0)
{
System.out.println(x8);
System.out.println("Le taux de l'erreur Account locked est :" );
System.out.println((100 * x8) / S);
}
if (x9!=0)
{
System.out.println(x9);
System.out.println("Le taux de l'erreur Account balance is less than the requested amount to debit or reserve est :" );
System.out.println((100 * x9) / S);
}
if (x10!=0)
{
System.out.println(x10);
System.out.println("Le taux de l'erreur Subscriber unknown est :" );
System.out.println((100 * x10) / S);
}
if (x11!=0)
{
System.out.println(x11);
System.out.println("Le taux de l'erreur Account unknown est :" );
System.out.println((100 * x11) / S);
}
if (x12!=0)
{
System.out.println(x12);
System.out.println("Le taux de l'erreur Could not charge chargedParty. Origin or Destination does not exist est :" );
System.out.println((100 * x12) / S);
}
if (x13!=0)
{
System.out.println(x13);
System.out.println("Le taux de l'erreur Could not determine tariff plan est :" );
System.out.println((100 * x13) / S);
}
if (x14!=0)
{
System.out.println(x14);
System.out.println("Le taux de l'erreur Account unavailable est :" );
System.out.println((100 * x14) / S);
}
if (x15!=0)
{
System.out.println(x15);
System.out.println("Le taux de l'erreur Subscriber is Blacklisted est :" );
System.out.println((100 * x15) / S);
}
if (x16!=0)
{
System.out.println(x16);
System.out.println("Le taux de l'erreur Reservation Error est :" );
System.out.println((100 * x16) / S);
}
if (x17!=0)
{
System.out.println(x17);
System.out.println("Le taux de l'erreur Rating error est :" );
System.out.println((100 * x17) / S);
}
if (x18!=0)
{
System.out.println(x18);
System.out.println("Le taux de l'erreur Missing parameter est :" );
System.out.println((100 * x18) / S);
}
if (x19!=0)
{
System.out.println(x19);
System.out.println("Le taux de l'erreur Invalid format of parameter est :" );
System.out.println((100 * x19) / S);
}
if (x20!=0)
{
System.out.println(x20);
System.out.println("Le taux de l'erreur Unknown chargeSessionId est :" );
System.out.println((100 * x20) / S);
}
if (x21!=0)
{
System.out.println(x21);
System.out.println("Le taux de l'erreur Invalid operation, post-paid user. Try Rate and Debit est :" );
System.out.println((100 * x21) / S);
}
if (x22!=0)
{
System.out.println(x22);
System.out.println("Le taux de l'erreur System temporarily unavailable est :" );
System.out.println((100 * x22) / S);
}
if (x23!=0)
{
System.out.println(x23);
System.out.println("Le taux de l'erreur System error est :" );
System.out.println((100 * x23) / S);
}
final StatisticalBarChartDemo demo = new StatisticalBarChartDemo("Statistical Bar Chart Demo" );
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
T[0]=0;T[1]=x1;T[2]=x2;T[3]=x3;T[4]=x4;T[5]=x5;T[6]=x6;T[7]=x7;T[8]=x8;T[9]=x9;T[10]=x10;T[11]=x11;T[12]=x12;
T[13]=x13;T[14]=x14;T[15]=x15;T[16]=x16;T[17]=x17;T[18]=x18;T[19]=x19;T[20]=x20;T[21]=x21;T[22]=x22;T[23]=x23;
}
catch (Exception e)
{
e.printStackTrace();
}
//for (int i = 0; i<=T.length; i++)
return T;
}
private static String saisie_string() throws IOException {
BufferedReader inr = new BufferedReader(
new InputStreamReader(System.in));
// String s = inr.readLine();
return (inr.readLine());
}
}