Files CSV!

Bom dia!

Eu tenho um ficheiro Csv com o seguinte formato!

[quote]
,SRFF File: D:\SPI Master program list\240-36-01_eng\240-36-01-B-01-E.SRF
,Panel Name: Panel Description,Lot Code: N/A,Device: N/A
,Units: Microns

,Date,Time,PanelId,Board,Location,Feature,HeightResult,Height,HeightUpFail,HeightLowFail,HeightTarget,AreaResult,Area,AreaUpFail,AreaLowFail,AreaTarget,VolumeResult,Volume,VolumeUpFail,VolumeLowFail,VolumeTarget,Valid,RegResult,XOffset,YOffset,RegShort%,RegLong%,RegShort%Fail,RegLong%Fail,BridgeResult,BridgeLength,BridgeFail

,07/08/2008,17:20:28,#1,Module 1,C181,Pad1 ,W,87.302147,212.5,75.0,125.0,P,211899.703125,383880,127960,255920,W,18802780.000000,57582032,15995009,31990018,P,P,-97.170998,11.670000,21.023582,2.107640, 40, 40,P,0.000000,700.000000
,07/08/2008,17:20:28,#1,Module 1,C181,Pad2 ,W,87.071892,212.5,75.0,125.0,P,203649.000000,383880,127960,255920,W,17642690.000000,57582032,15995009,31990018,P,P,-100.944099,-9.680000,21.839918,1.748239, 40, 40,P,0.000000,700.000000
,07/08/2008,17:20:28,#1,Module 1,C176,Pad1 ,P,89.921509,212.5,75.0,125.0,P,212768.906250,383880,127960,255920,W,18684450.000000,57582032,15995009,31990018,P,P,-99.287102,34.439999,21.481415,6.219975, 40, 40,P,0.000000,700.000000
,07/08/2008,17:20:28,#1,Module 1,C176,Pad2 ,F,106.477997,212.5,75.0,125.0,P,188879.406250,383880,127960,255920,P,19587040.000000,57582032,15995009,31990018,P,P,-89.126198,11.310000,19.283037,2.042622, 40, 40,P,0.000000,700.000000[/quote]

e eu tenho uma classe que primeiro estabelece uma ligaçao servidor remotamente
depois acede ao folder que contem os ficheiros csv através de um scaning recursivo!
ao aceder ao ficheiro vai contar os erros neste caso apresentado por um “F”.

Agora eu tenho uma parte de script que encontrei que me iria ajudar a retirar os valores adjacentes… e.g. F, 106.477997, 212.5,75.0, 125.0 - 07/08/2008,17:20:28,#1,Module 1,C176,Pad2
HeightResult, Height, HeightUpFail, HeightLowFail, HeightTarget - Date, time, Board, Location, feature!

este é o script:

[code]
public class InspectionResults{ public static final byte HEIGHT_AVG_RESULT = 7, HEIGHT_RANGE_RESULT = 12, AREA_AVG_RESULT = 15, AREA_RANGE_RESULT = 20, VOLUME_AVG_RESULT = 23, VOLUME_RANGE_RESULT = 28, HAV_FAILED_FEATURE_RESULT = 35, REG_FAILED_FEATURE_RESULT = 38, BRIDGE_FAILED_FEATURE_RESULT = 41; private String retrievedData[]; private boolean failed[]; /** * Constructs this InspectionResult with the data stored in the args. * This class expects 44 values within the range of the args. / public InspectionResults(String… args){ retrievedData = args; boolean temp[] ={ ((retrievedData[7].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[12].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[15].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[20].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[23].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[28].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[35].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[38].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[41].equalsIgnoreCase(“F”)) ? true: false) }; failed = temp; } /* * Returns true if the given value has failed, returns false otherwise. * It’s preferred to use the constants defined within this class to get the * desired information, and not regular ints. / public boolean hasFailed(byte result) throws Exception{ switch(result){ case HEIGHT_AVG_RESULT: return failed[0]; case HEIGHT_RANGE_RESULT: return failed[1]; case AREA_AVG_RESULT: return failed[2]; case AREA_RANGE_RESULT: return failed[3]; case VOLUME_AVG_RESULT: return failed[4]; case VOLUME_RANGE_RESULT: return failed[5]; case HAV_FAILED_FEATURE_RESULT: return failed[6]; case REG_FAILED_FEATURE_RESULT: return failed[7]; case BRIDGE_FAILED_FEATURE_RESULT: return failed[8]; default : throw new Exception(“Attempt to access invalid result type! Use the Result Constants to avoid this error!”); } } /* * Returns the value next to the specified result. / public String getAdjacentValue(byte result) throws Exception{ if(result >= 0 && result < retrievedData.length - 1) return retrievedData[result + 1]; else throw new Exception(“Error! Attempt to access column with either no adjacent value or outside of data-range!”); } /* * Simply returns a String representing the date for each value in this class. */ @Override public String toString(){ String temp = “”; for(String element : retrievedData){ if(element.toString() != retrievedData[retrievedData.length - 1]) temp += element + ", "; else temp += element; } return temp; }}public class InspectionResults{

public static final byte  HEIGHT_AVG_RESULT = 7,
						  HEIGHT_RANGE_RESULT = 12,
						  AREA_AVG_RESULT = 15,
						  AREA_RANGE_RESULT = 20,
						  VOLUME_AVG_RESULT = 23,
						  VOLUME_RANGE_RESULT = 28,
						  HAV_FAILED_FEATURE_RESULT = 35,
						  REG_FAILED_FEATURE_RESULT = 38,
						  BRIDGE_FAILED_FEATURE_RESULT = 41;
private String retrievedData[];
private boolean failed[];

/**
 * Constructs this InspectionResult with the data stored in the args.
 * This class expects 44 values within the range of the args.
 */
public InspectionResults(String... args){
	retrievedData = args;
	boolean temp[] ={
		((retrievedData[7].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[12].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[15].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[20].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[23].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[28].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[35].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[38].equalsIgnoreCase("F")) ? true: false),
		((retrievedData[41].equalsIgnoreCase("F")) ? true: false)
	};
	failed = temp;
}

/**
 * Returns true if the given value has failed, returns false otherwise.
 * It's preferred to use the constants defined within this class to get the
 * desired information, and not regular ints.
 */
public boolean hasFailed(byte result) throws Exception{
	switch(result){
		case HEIGHT_AVG_RESULT:
			return failed[0];
		case HEIGHT_RANGE_RESULT:
			return failed[1];
		case AREA_AVG_RESULT:
			return failed[2];
		case AREA_RANGE_RESULT:
			return failed[3];
		case VOLUME_AVG_RESULT:
			return failed[4];
		case VOLUME_RANGE_RESULT:
			return failed[5];
		case HAV_FAILED_FEATURE_RESULT:
			return failed[6];
		case REG_FAILED_FEATURE_RESULT:
			return failed[7];
		case BRIDGE_FAILED_FEATURE_RESULT:
			return failed[8];
		default :
			throw new Exception("Attempt to access invalid result type! Use the Result Constants to avoid this error!");
	}
}

/**
 * Returns the value next to the specified result.
 */
public String getAdjacentValue(byte result) throws Exception{
	if(result >= 0 && result < retrievedData.length - 1)
		return retrievedData[result + 1];
	else throw new Exception("Error! Attempt to access column with either no adjacent value or outside of data-range!");
}

/**
 * Simply returns a String representing the date for each value in this class.
 */
@Override
public String toString(){
	String temp = "";
	for(String element : retrievedData){
		if(element.toString() != retrievedData[retrievedData.length - 1])
			temp += element + ", ";
		else temp += element;
	}
	return temp;
}

}[/code]

só que não sei como utilizar… alguem me pode ajudar?

Obrigado… estive parado durante 1.5 anos e estou muito enferrujado!

Cara, blz.
Você colocou a informação do arquivo dentro da citação e isso escondeu um pedaço dele, vc também colocou duas vezes o código :?
Mas vamos lá.
Pelo que entendi para o construtor da classe você tem que passar como argumento a linha do ficheiro desse modo:
(“07/08/2008” “17:20:28” “#1” “Module 1” “etc…”)

O construtor vai comparar as posiçôes definidas por : 7,12,15,etc… com “F” e vai armazenar no vetor “temp” que vai ser copiado para o vetor “failed”.

Na função “hasFailed” você vai passar as variáveis HEIGHT_AVG_RESULT, HEIGHT_RANGE_RESULT,etc e a função te retorna se falhou ou não.

Se a função “hasFailed” retornou false você joga na função “getAdjacentValue” que ela vai te retorna o valor adjacente.

Acho que é isso.
Obs:
1-no caso do construtor seria bom colocar as variáveis HEIGHT_AVG_RESULT,etc. no lugar dos números 7,etc. para buscar a informação no vetor “retrieveData”
2-O construtor espera que a linha tenha 44 argumentos, mas no ficheiro que você passou parece que só tem 32, verifica ai.

Falou…

Boas!

Na teoria é isso mesmo que acabou de dizer…
Mas o meu problema é que estes ficheiros de CSV são criados pelo equipamento… alguns tem 44 e outros tem 32 como viu… No entanto estou a tentar adaptar de modo a que leia os 2…

primeiro vê a quantidade de argumentos… se for 32…

else …

Eu não consigo utilizar o Script que apresentei… estou completamente perdido… sei quando colocar…

na altura em que o codigo acede ao ficheiro atraves do metodo recursivo

Pode-me ajudar

Blz, não entendi em que ponto você está confuso, pelo que percebi é só utilizar dessa forma que você falou.

Leia o arquivo, pegue o tamanho da linha.

if (tamanhoDaLinha == 32){
    //passa os 32 parametros para o construtor
}else{
    //passa os 42
}

Depois seta as variáveis HEIGHT_AVG_RESULT, HEIGHT_RANGE_RESULT, etc com os valores das posições correspondentes.
Como tinha falado anteriormente, utilize essas variáveis no vetor retrievedData, já que as posições podem não ser fixas.

Para cada valor dessas variáveis chama o hasFailed (ex. hasFailed(HEIGHT_AVG_RESULT))
e caso de falso chame o getAdjacentValue passando esse valor (ex. getAdjacentValue(HEIGHT_AVG_RESULT)).
Você receberá o valor adjacente ao que falhou.

Isso é o que da pra tirar desses códigos que você passou.
Espero ter clareado.

Falou.

Não sei como dizer… até me sinto mal!

mas não consigo chamar o construtor a partir do codigo principal… não está a funcionar…
na teoria é como você diz… mas depois na pratica estou a falhar…

como utilizo?

 InspectionResults

no codigo recursivo!!!

[code]/* …Recursive list… */
public void listRecursively(File fdir, int depth) throws IOException {

	/*Transform milliseconds time to gregorian time */
	long datefiles = fdir.lastModified();
	SimpleDateFormat Date = new SimpleDateFormat (" dd/MM/yyyy , HH:mm:ss aaa");
	Date nDate = new Date(datefiles);
	
	String F = ",F,";
	int count = 0;
	
	/*Line counter*/
	try
	{
		RandomAccessFile File = new RandomAccessFile(fdir,"r");
		long lastline=File.length();
		File.close();
		
		FileReader fileRead = new FileReader(fdir);
		BufferedReader bufferReader = new BufferedReader(fileRead);
		
		Scanner scan = new Scanner(fdir);
		while(scan.hasNextLine())
		{
			if(scan.nextLine().contains(F))
				count++;
		}
		
		fileRead.close();
		bufferReader.close();

// /Start Line counter mode2/
// LineNumberReader lineRead = new LineNumberReader(fileRead);
// lineRead.skip(lastline);
// int countline = lineRead.getLineNumber()-6; //number of default lines = 6
// fileRead.close();
// lineRead.close();
// /End Line counter mode2/

	/* Output1 */
		if (fdir.getPath().endsWith(".csv") /*&& fdir.lastModified() > HostFile.lastModified()*/)
			System.out.println(INDENTS[depth] + x +", "+fdir.getName() +", "+ count +","+Date.format(nDate));
	/* Output2 */
		if (fdir.getPath().endsWith(".csv") /*&& fdir.lastModified() > HostFile.lastModified()*/)
			fw.write( INDENTS[depth] + x +", "+ fdir.getName() +", "+ count +","+ Date.format(nDate)+ System.getProperty("line.separator"));
		fw.flush();
	//if (fdir.getPath().endsWith(".csv") && (fdir.length()/512 )>= 1 && fdir.length()/512 <= 3)	
	}
	catch(IOException e){
	} 
	if (fdir.isDirectory() && !fdir.isHidden() && depth < MAX_DEPTH) {
		for (File f : fdir.listFiles()){  // Go over each file/subdirectory.
			listRecursively(f, depth+1);
			}}}

[/code]

Esta recursividade vai ser utilizada depois da aplicação aceder remotamente à maquina e fazer scanner aos ficheiros csv…

agora não sei como implementar o InspectionResults…

o resultado da aplicação principal está a ser armazenado em ficheiros txt correspondentes a cada maquina! tenho 20 maquinas para monitorizar… o que consegui fazer com o scanner foi contar o numero de falhas que cada csv tem - F- agora pretendia utilizar o InspectionResults para obter a restante informação… mas estou completamente desfeito… a minha cabeça parece que vai rebentar…

Mas desde já valeu pelo auxilio…

Blz,
você utilizaria o InspectionResults nesse pedaço

while(scan.hasNextLine())  
   {  
       linha = scan.nextLine();
       if (linha.contains(F))
            count++;
       //alguma coisa próxima disso
       inspectionResults =  new InspectionResults(linha.split()); //só uma idéia do parametro a passar.
        if (linha.split().length()==32){//arquivo com 32 linha, lembrando que não é bom colocar números soltos no código ,hehe
             //sete as variaveis HEIGHT_AVG_RESULT,etc com as posições correspondentes.
             
        }else{//arquivo com 44
             //sete as variaveis HEIGHT_AVG_RESULT,etc com as posições correspondentes.             
        }
         if(inspectionResults.hasFailed(HEIGHT_AVG_RESULT)){// faz isso para todas as variáveis.
             valorAdjacente = getAdjacentValue(HEIGHT_AVG_RESULT);
         }
         /////fim
   }  

Usando essa idéia acho que consegue recuperar os valores adjacentes. :?

Ps: Esse método recursivo que vc passou me parece que pega o primeiro arquivo em cada diretório, verifica ae.
Falou…

Valeu a ajuda… durante o fim de semana estive a tentar rever as minhas falhas… entretanto cheguei a esta fase: por exemplo para o codigo para as 32 colunas:

[code]
package spimonitoring;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.reflect.Array;

public class InspectionResults32{

/*,Date,Time,PanelId,Board,Location,Feature,

  • HeightResult6,Height,HeightUpFail,HeightLowFail,

  • HeightTarget,AreaResult11,Area,AreaUpFail,AreaLowFail,

  • AreaTarget,VolumeResult16,Volume,VolumeUpFail,VolumeLowFail,

  • VolumeTarget,Valid,RegResult22,XOffset,YOffset,RegShort%,

  • RegLong%,RegShort%Fail,RegLong%Fail,BridgeResult29,BridgeLength,BridgeFail*/

    public static final byte HEIGHT_RESULT = 6,
    AREA_RESULT = 11,
    VOLUME_RESULT = 16,
    REG_RESULT = 22,
    BRIDGE_RESULT = 29;

    private String retrievedData[];
    private boolean failed[];

    /**

    • Constructs this InspectionResult with the data stored in the args.
    • This class expects 44 values within the range of the args.
      */
      public InspectionResults32(String… args){
      retrievedData = args;
      boolean temp[] ={
      ((retrievedData[6].equalsIgnoreCase(“F”)) ? true: false),
      ((retrievedData[11].equalsIgnoreCase(“F”)) ? true: false),
      ((retrievedData[16].equalsIgnoreCase(“F”)) ? true: false),
      ((retrievedData[22].equalsIgnoreCase(“F”)) ? true: false),
      ((retrievedData[29].equalsIgnoreCase(“F”)) ? true: false)
      };
      failed = temp;
      }
      static class MyArrays{
      public static T[] copyOfRange(T[] array, T[] emptyArray, int from, int size){
      ArrayList temp = new ArrayList(0);
      for(int i = from; i < size; i++){
      temp.add(array[i]);
      }
      return temp.toArray(emptyArray);
      }
      }

    public static void main(String… args){

     FileReader fr = null;
     BufferedReader br = null;
     try{
     	fr = new FileReader(new File("C:\\Documents and Settings\\florenci.QIMONDA\\Desktop\\spi15\\SE 300 Output\\CSV\\240-36-01-B-01-E.F.T.#1001.4874de2b.spi.csv"));
     	br = new BufferedReader(fr);
     }catch(Exception e){e.printStackTrace();}
    
    
     String dwArray[][] ={ {""}, {""}, {""} };
    
     for(int i = 0; i < dwArray.length; i++){
     	String temp[] = null;
    
     	try{ temp = br.readLine().split(",");
     	}
     	catch(Exception f){f.printStackTrace(); 
     	System.exit(1);
     	};
     	String empty[] = {};
     	temp = InspectionResults32.MyArrays.<String>copyOfRange(temp, empty, 1, temp.length);			
     			
     	dwArray[i] = temp;
     }
    
    
     InspectionResults32 ir[] =
     {
     	new InspectionResults32(dwArray[0]),
     	new InspectionResults32(dwArray[1]),
     	new InspectionResults32(dwArray[2])
     };
    
     System.out.println(ir[0]); // as an example
     spacer(3);
    
     try{
     	System.out.println(ir[0].hasFailed(InspectionResults32.HEIGHT_RESULT));
     	System.out.println(ir[0].getAdjacentValue(InspectionResults32.HEIGHT_RESULT));
     	System.out.println(ir[0].hasFailed(InspectionResults32.AREA_RESULT));
     	System.out.println(ir[0].getAdjacentValue(InspectionResults32.AREA_RESULT));
     	System.out.println(ir[0].hasFailed(InspectionResults32.VOLUME_RESULT));
     	System.out.println(ir[0].getAdjacentValue(InspectionResults32.VOLUME_RESULT));
     	System.out.println(ir[0].hasFailed(InspectionResults32.REG_RESULT));
     	System.out.println(ir[0].getAdjacentValue(InspectionResults32.REG_RESULT));
     	System.out.println(ir[0].hasFailed(InspectionResults32.BRIDGE_RESULT));
     	System.out.println(ir[0].getAdjacentValue(InspectionResults32.BRIDGE_RESULT));
     }catch(Exception e){
     	System.out.println(e);
     }
    
     try{
     	fr.close();
     	br.close();
     }catch(Exception e){
     }
    

    }

    private static void spacer(int lines){
    for(int i = 0; i < lines; i++)
    System.out.println();
    }

    /**

    • Returns true if the given value has failed, returns false otherwise.
    • It’s preferred to use the constants defined within this class to get the
    • desired information, and not regular ints.
      */
      public boolean hasFailed(byte result) throws Exception{
      switch(result){
      case HEIGHT_RESULT:
      return failed[0];
      case AREA_RESULT:
      return failed[1];
      case VOLUME_RESULT:
      return failed[2];
      case REG_RESULT:
      return failed[3];
      case BRIDGE_RESULT:
      return failed[4];
      default :
      throw new Exception(“Attempt to access invalid result type! Use the Result Constants to avoid this error!”);
      }
      }

    /**

    • Returns the value next to the specified result.
      */
      public String getAdjacentValue(byte result) throws Exception{
      if(result >= 0 && result < retrievedData.length - 1)
      return retrievedData[result + 1];
      else throw new Exception(“Error! Attempt to access column with either no adjacent value or outside of data-range!”);
      }

    /**

    • Simply returns a String representing the data for each value in this class.
      */
      @Override
      public String toString(){
      String temp = “”;
      for(String element : retrievedData){
      if(element.toString() != retrievedData[retrievedData.length - 1])
      temp += element + ", ";
      else temp += element;
      }
      return temp;
      }

}[/code]

que origina o output pretendido…

Obrigadão pela ajuda…

Relativamente ao Scan… o que ele está a fazer é percorrer recursivamente todos os folders e ler somente os ficheiros csv… tentando encontrar quantos -F- tem no texto todo… como isso limitava muito o trabalho… pretendi ver se tem - F - queria poder identificar… daí o codigo InspectionResult…

O objectivo será criar um output com a seguinte ordem:

Equipamento, ficheiro, numero de falhas , data, hora, HEIGHT_RESULT, AREA_RESULT,VOLUME_RESULT,REG_RESULT,BRIDGE_RESULT.
3, 184-32-03-T-01-R.F.T.#20.488af413.spi.csv, 10, 26/07/2008 , 17:53:23 PM , 2, 2, 2, 2, 2…

ainda estou em tentativas… mas vamos lá ver…

Boas!!!

Este é o codigo que me permite retirar os valores pretendidos

[code]package spimonitoring;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.reflect.Array;

public class InspectionResults44{

public static final byte  HEIGHT_AVG_RESULT = 6,
						  HEIGHT_RANGE_RESULT = 11,
						  AREA_AVG_RESULT = 16,
						  AREA_RANGE_RESULT = 22,
						  VOLUME_AVG_RESULT = 29,
						  VOLUME_RANGE_RESULT = 28,
						  HAV_FAILED_FEATURE_RESULT = 35,
						  REG_OFF_RESULT = 38,
						  BRIDGE_LEN_RESULT = 41;

private String retrievedData[];
private boolean failed[];



/**
 * Constructs this InspectionResult with the data stored in the args.
 * This class expects 44 values within the range of the args.
 */
public InspectionResults44(String... args){
	retrievedData = args;
	boolean temp[] ={
		((retrievedData[6].equalsIgnoreCase("F")) ? true: false),//7
		((retrievedData[11].equalsIgnoreCase("F")) ? true: false),//12
		((retrievedData[16].equalsIgnoreCase("F")) ? true: false),//15
		((retrievedData[22].equalsIgnoreCase("F")) ? true: false),//20
		((retrievedData[29].equalsIgnoreCase("F")) ? true: false),//23

// ((retrievedData[28].equalsIgnoreCase(“F”)) ? true: false),//28
// ((retrievedData[35].equalsIgnoreCase(“F”)) ? true: false),
// ((retrievedData[38].equalsIgnoreCase(“F”)) ? true: false),
// ((retrievedData[41].equalsIgnoreCase(“F”)) ? true: false)
};
failed = temp;
}
static class MyArrays{
public static T[] copyOfRange(T[] array, T[] emptyArray, int from, int size){
ArrayList temp = new ArrayList(0);
for(int i = from; i < size; i++){
temp.add(array[i]);
}
return temp.toArray(emptyArray);
}
}

public static void main(String... args){

	String line = null;
	int countline = 0;
	int startAtLineNo = 7; 
	
	FileReader fr = null;
	BufferedReader br = null;
	try{
		fr = new FileReader(new File("K:\\Spi5\\240-25-04-B-02-R1.F.T.#10.489a5f8e.spi.csv"));
		br = new BufferedReader(fr);
	}catch(Exception e){e.printStackTrace();}


	String dwArray[][] ={ {""}, {""}, {""} };

	try {
		while ((line = br.readLine()) != null) {
			  if (countline >= startAtLineNo) {
		
				  for(int i = 0; i < dwArray.length; i++){
					  String temp[] = null;

					  try{ temp = br.readLine().split(",");
					  }
					  catch(Exception f){f.printStackTrace(); 
					  System.exit(1);
					  };
					  String empty[] = {};
					  temp = InspectionResults44.MyArrays.<String>copyOfRange(temp, empty, 1, temp.length);			

					  dwArray[i] = temp;
				  }


				  InspectionResults44 ir[] =
				  {
						  new InspectionResults44(dwArray[0]),
						  new InspectionResults44(dwArray[1]),
						  new InspectionResults44(dwArray[2])
				  };

				  System.out.println(ir[0]); // as an example
				  spacer(3);

				  try{
					  System.out.println(ir[0].hasFailed(InspectionResults32.HEIGHT_AVG_RESULT));
					  System.out.println(ir[0].getAdjacentValue(InspectionResults32.HEIGHT_AVG_RESULT));
					  System.out.println(ir[0].hasFailed(InspectionResults32.AREA_AVG_RESULT));
					  System.out.println(ir[0].getAdjacentValue(InspectionResults32.AREA_AVG_RESULT));
					  System.out.println(ir[0].hasFailed(InspectionResults32.VOLUME_AVG_RESULT));
					  System.out.println(ir[0].getAdjacentValue(InspectionResults32.VOLUME_AVG_RESULT));
					  System.out.println(ir[0].hasFailed(InspectionResults32.REG_OFF_RESULT));
					  System.out.println(ir[0].getAdjacentValue(InspectionResults32.REG_OFF_RESULT));
					  System.out.println(ir[0].hasFailed(InspectionResults32.BRIDGE_LEN_RESULT));
					  System.out.println(ir[0].getAdjacentValue(InspectionResults32.BRIDGE_LEN_RESULT));
				  }catch(Exception e){
					  System.out.println(e);
				  }
			  }countline++;
		}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}

private static void spacer(int lines){
	for(int i = 0; i < lines; i++)
		System.out.println();
}



 
/**
 * Returns true if the given value has failed, returns false otherwise.
 * It's preferred to use the constants defined within this class to get the
 * desired information, and not regular ints.
 */
public boolean hasFailed(byte result) throws Exception{
	switch(result){
		case HEIGHT_AVG_RESULT:
			return failed[0];
		case HEIGHT_RANGE_RESULT:
			return failed[1];
		case AREA_AVG_RESULT:
			return failed[2];
		case AREA_RANGE_RESULT:
			return failed[3];
		case VOLUME_AVG_RESULT:
			return failed[4];
		case VOLUME_RANGE_RESULT:
			return failed[5];
		case HAV_FAILED_FEATURE_RESULT:
			return failed[6];
		case REG_OFF_RESULT:
			return failed[7];
		case BRIDGE_LEN_RESULT:
			return failed[8];
		default :
			throw new Exception("Attempt to access invalid result type! Use the Result Constants to avoid this error!");
	}
}

/**
 * Returns the value next to the specified result.
 */
public String getAdjacentValue(byte result) throws Exception{
	if(result >= 0 && result < retrievedData.length - 1)
		return retrievedData[result + 1];
	else throw new Exception("Error! Attempt to access column with either no adjacent value or outside of data-range!");
}

/**
 * Simply returns a String representing the data for each value in this class.
 */
@Override
public String toString(){
	String temp = "";
	for(String element : retrievedData){
		if(element.toString() != retrievedData[retrievedData.length - 1])
			temp += element + ", ";
		else temp += element;
	}
	return temp;
}

[/code]

so que quando tento integrar no codigo principal…

[quote] public void listRecursively(File fdir, int depth) throws IOException {

	/*Transform milliseconds time to gregorian time */
	long datefiles = fdir.lastModified();
	SimpleDateFormat Date = new SimpleDateFormat (" dd/MM/yyyy , HH:mm:ss aaa");
	Date nDate = new Date(datefiles);

	String F = ",F,";
	String Height = null;
	String Area = null;
	String Volume = null;
	String RegOffset = null;
	String Bridging = null;
	
	String line = null;
	int countline = 0;
	int startAtLineNo = 7;	
	
	int count = 0;
		
	int countHeight = 0,
	 countArea = 0,
	 countVolume = 0,
	 countRegOffset = 0,
	 countBridging = 0;

	/*Line counter*/
	try
	{
		RandomAccessFile File = new RandomAccessFile(fdir,"r");
		long lastline=File.length();
		File.close();
		
		FileReader fileRead = new FileReader(fdir);
		BufferedReader bufferReader = new BufferedReader(fileRead);
		String dwArray[][] ={ {""}, {""}, {""} };
		Scanner scan = new Scanner(fdir);
		
		while(scan.hasNextLine())
		{
			if(scan.nextLine().contains(F))
				count++;
		}
		
		fileRead.close();
		bufferReader.close();//___________________________original
		
		InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));
		
		while ((line = bufferReader.readLine()) != null) {
			if (countline >= startAtLineNo) {
				if (line.split(",").length == 32){
					HEIGHT_AVG_RESULT = 6;
					AREA_AVG_RESULT = 11;
					VOLUME_AVG_RESULT = 16;
					REG_OFF_RESULT = 22;
					BRIDGE_LEN_RESULT = 29;
				} else{//File with 44
					HEIGHT_AVG_RESULT = 7;
					HEIGHT_RANGE_RESULT = 12;
					AREA_AVG_RESULT = 15;
					AREA_RANGE_RESULT = 20;
					VOLUME_AVG_RESULT = 23;
					VOLUME_RANGE_RESULT = 28;
					HAV_FAILED_FEATURE_RESULT = 35;
					REG_OFF_RESULT = 38;
					BRIDGE_LEN_RESULT = 41;
				}			
				
				try {
					if(inspectionResults.hasFailed(InspectionResults44.HEIGHT_AVG_RESULT)){
						Height = inspectionResults.getAdjacentValue(InspectionResults44.HEIGHT_AVG_RESULT);
						countHeight++;
					}
					if(inspectionResults.hasFailed(InspectionResults44.AREA_AVG_RESULT)){
						Area = inspectionResults.getAdjacentValue(InspectionResults44.AREA_AVG_RESULT);
						countArea++;
					}
					if(inspectionResults.hasFailed(InspectionResults44.VOLUME_AVG_RESULT)){
						Area = inspectionResults.getAdjacentValue(InspectionResults44.VOLUME_AVG_RESULT);
						countVolume++;
					}
					if(inspectionResults.hasFailed(InspectionResults44.REG_OFF_RESULT)){
						Area = inspectionResults.getAdjacentValue(InspectionResults44.REG_OFF_RESULT);
						countRegOffset++;
					}
					if(inspectionResults.hasFailed(InspectionResults44.BRIDGE_LEN_RESULT)){
						Area = inspectionResults.getAdjacentValue(InspectionResults44.BRIDGE_LEN_RESULT);
						countBridging++;
					}}
				catch (Exception e) {
					e.printStackTrace();
				}
				fileRead.close();
				bufferReader.close();
			}}

// /Start Line counter mode2/
// LineNumberReader lineRead = new LineNumberReader(fileRead);
// lineRead.skip(lastline);
// int countline = lineRead.getLineNumber()-6; //number of default lines = 6
// fileRead.close();
// lineRead.close();
// /End Line counter mode2/

		/* Output1 */
		if (fdir.getPath().endsWith(".csv") /*&& fdir.lastModified() > HostFile.lastModified()*/)
			System.out.println(INDENTS[depth] + x +", "+fdir.getName() +", "+ count +","+Date.format(nDate) + "," + countHeight + "," + countArea + "," + countVolume + "," + countRegOffset + "," + countBridging);
		/* Output2 */
		if (fdir.getPath().endsWith(".csv") /*&& fdir.lastModified() > HostFile.lastModified()*/)
			fw.write( INDENTS[depth] + x +", "+ fdir.getName() +", "+ count +","+ Date.format(nDate)+ System.getProperty("line.separator"));
		fw.flush();
		//if (fdir.getPath().endsWith(".csv") && (fdir.length()/512 )>= 1 && fdir.length()/512 <= 3)	
	}
	catch(IOException e){
	} 
	if (fdir.isDirectory() && !fdir.isHidden() && depth < MAX_DEPTH) {
		for (File f : fdir.listFiles()){  // Go over each file/subdirectory.
			listRecursively(f, depth+1);
		}}}

[/quote]

me dá erro

[quote]
alguem me pode ajudar… valeu