Exception

17 respostas
J

Olá! EU estou a ter problemas com o java.lang.NullPointerException…

será que me pode ajudar!

O codigo que se segue, funciona quando tabalhando sozinho!

view plaincopy to clipboardprint?

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> T[] copyOfRange(T[] array, T[] emptyArray, int from, int size){
			ArrayList<T> temp = new ArrayList<T>(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;
		
		String Height = null;
		String Area = null;
		String Volume = null;
		String RegOffset = null;
		String Bridging = null;
		
		int countHeight = 0,
		 countArea = 0,
		 countVolume = 0,
		 countRegOffset = 0,
		 countBridging = 0;
		
		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[1]); // as an example
					  spacer(1);

					  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;
	}
	
	
}

agora num metodo recursivo… está a dar erro null pointer…

eis o codigo
view plaincopy to clipboardprint?

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();   
                }}   
  
            /* 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);   
            }}}

o codigo recursivo por sua vez é utilizado da seguinte forma…

/* ---------------------SPI01----------------------- */   
                /*Creates the Object file SPI1.log */   
                //outputFrame.aTextArea.setText("");   
                File f1 = new File("E:\\public\\Log\\Log\\SPI01.log");   
                if(f1.exists())   
                    //System.out.println("Log File SPI01..................................... Done;");   
                    setMessage("Log File SPI01..................................... Done;");   
                /* if it doesn't exists */   
                if(!f1.exists())   
                    //System.out.println("The Log file does not exist");   
                    setMessage("The Log file does not exist");   
                /* New file ... exception popup */   
                try {   
                    if(f1.createNewFile())   
                        //System.out.println("Log file created.................................. Done;");   
                        setMessage("Log file created.................................. Done;");   
                }   
                catch (IOException e) {   
                    //System.out.println("I/O Error");   
                    setMessage("I/O Error");   
                }   
                /*Creates the Object file LD01.log */   
                File ff1 = new File("E:\\public\\Log\\LotData\\LD01.log");   
                if(ff1.exists())   
                    //System.out.println("LotData SPI01..................................... done;");   
                    setMessage("LotData SPI01..................................... done;");   
                /* if it doesn't exists */   
                if(!ff1.exists()){   
                    setMessage("The LotData file does not exist");   
                    //System.out.println("The LotData file does not exist");   
                    /* New file ... exception popup */   
                    try {   
                        if(ff1.createNewFile())   
                            //System.out.println("LotData file created.................................. done;");   
                            setMessage("LotData file created.................................. done;");   
                    }   
                    catch (IOException e) {   
                        //System.out.println("I/O Error");   
                        setMessage("I/O Error");   
                    }   
                }         
  
                /* mapping */   
                /*   Creates a temporary Network Drive before starting the cycle */   
                String mapSPI01 = new String("net use z: \\\\172.21.34.1\\d$ qmy001 /user:172.21.34.1\\administrator /Persistent:No");               
                Runtime rt = Runtime.getRuntime();   
                try     {   
                    Process con = rt.exec(mapSPI01);   
                    con.waitFor();   
                    //System.out.println("Drive mapping Spi 01......................... Done");   
                    setMessage("Drive mapping Spi 01......................... Done");   
                }   
                catch (IOException e)   {   
                    System.out.println(e);   
                }   
                catch (InterruptedException e) {   
                    // TODO Auto-generated catch block   
                    e.printStackTrace();   
                }   
  
                /*Copy LotData contents from d:\DataLot\LotData.csv to the Respective LD.log*/   
                try {         
                    if (LotInput.isDirectory()) {   
                        //fos = new FileOutputStream(HostFileLD01);     
                        files = LotInput.listFiles();   
                        xw = new FileWriter(HostFileLD01);   
  
                        for (int i = 0; i < files.length; i++) {         
                            file = files[i];         
  
                            fr = new FileReader(file);         
                            br = new BufferedReader(fr);   
                            x=1;   
  
                            while ((line = br.readLine()) != null) {   
                                //System.out.println(line);   
                                xw.write(x+","+line + System.getProperty("line.separator")) ;//change line   
                                xw.flush();   
                            }   
                        }   
  
                    }     
  
                }   
                catch (FileNotFoundException fnex) {         
                    fnex.printStackTrace();         
                }   
                catch (IOException ioex) {         
                    ioex.printStackTrace();         
                }   
                /*end of copy*/   
  
                setMessage("Collecting Data from SPI 01");   
                /* Scanning */   
                //File root = new File("z:\\SE300 Output");   
                File root = new File("K:\\Spi5");   
                if (root != null && root.isDirectory()) {   
                    try{   
                        fw = new FileWriter("E:\\public\\Log\\Log\\SPI01.log");   
                        x=5;   
                        listRecursively(root, 0);   
                        fw.close();   
                    }   
                    catch(NullPointerException np){   
                        np.printStackTrace();   
                    }   
                    catch(IOException exc){   
                        exc.printStackTrace();   
                    }   
                }   
                else   
                {   
                    //System.out.println("Not a directory: " + root);   
                    setMessage("Not a directory: " + root);}   
  
                /* Deletes temporary Network Drive before finishing the cycle */   
                try   
                {               
                    String[] cmd = new String[3];   
  
                    cmd[0] = "cmd.exe" ;   
                    cmd[1] = "/C" ;   
                    cmd[2] = "net use z: /delete /y";   
  
  
                    Runtime rtoff = Runtime.getRuntime();   
                    //System.out.println("Executing " + cmd[0] + " " + cmd[1]   
                    //                  + " " + cmd[2]);   
                    setMessage("Executing " + cmd[0] + " " + cmd[1]   
                                                                 + " " + cmd[2]);   
                    Process proc = rtoff.exec(cmd);   
  
                    // any error message?   
                    StreamGobbler1 errorGobbler = new   
                    StreamGobbler1(proc.getErrorStream(), "ERROR");               
  
                    // any output?   
                    StreamGobbler1 outputGobbler = new   
                    StreamGobbler1(proc.getInputStream(), "OUTPUT");   
  
                    // kick them off   
                    errorGobbler.start();   
                    outputGobbler.start();   
  
                    // any error???   
                            int exitVal = proc.waitFor();   
                            setMessage("ExitValue: " + exitVal);   
                } catch (Throwable t)   
                {   
                    t.printStackTrace();   
                }  

/* ---------------------SPI01----------------------- */
				/*Creates the Object file SPI1.log */
				//outputFrame.aTextArea.setText("");
				File f1 = new File("E:\\public\\Log\\Log\\SPI01.log"); 
				if(f1.exists())
					//System.out.println("Log File SPI01..................................... Done;");
					setMessage("Log File SPI01..................................... Done;");
				/* if it doesn't exists */
				if(!f1.exists())
					//System.out.println("The Log file does not exist");
					setMessage("The Log file does not exist");
				/* New file ... exception popup */
				try {
					if(f1.createNewFile())
						//System.out.println("Log file created.................................. Done;");
						setMessage("Log file created.................................. Done;");
				}
				catch (IOException e) {
					//System.out.println("I/O Error");
					setMessage("I/O Error");
				}
				/*Creates the Object file LD01.log */
				File ff1 = new File("E:\\public\\Log\\LotData\\LD01.log"); 
				if(ff1.exists())
					//System.out.println("LotData SPI01..................................... done;");
					setMessage("LotData SPI01..................................... done;");
				/* if it doesn't exists */
				if(!ff1.exists()){
					setMessage("The LotData file does not exist");
					//System.out.println("The LotData file does not exist");
					/* New file ... exception popup */
					try {
						if(ff1.createNewFile())
							//System.out.println("LotData file created.................................. done;");
							setMessage("LotData file created.................................. done;");
					}
					catch (IOException e) {
						//System.out.println("I/O Error");
						setMessage("I/O Error");
					}
				}		

				/* mapping */
				/*   Creates a temporary Network Drive before starting the cycle */
				String mapSPI01 = new String("net use z: \\\\172.21.34.1\\d$ qmy001 /user:172.21.34.1\\administrator /Persistent:No");            
				Runtime rt = Runtime.getRuntime();
				try     {
					Process con = rt.exec(mapSPI01);
					con.waitFor();
					//System.out.println("Drive mapping Spi 01......................... Done");
					setMessage("Drive mapping Spi 01......................... Done");
				}
				catch (IOException e)   {
					System.out.println(e);
				}
				catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

				/*Copy LotData contents from d:\DataLot\LotData.csv to the Respective LD.log*/
				try {       
					if (LotInput.isDirectory()) { 
						//fos = new FileOutputStream(HostFileLD01);   
						files = LotInput.listFiles();
						xw = new FileWriter(HostFileLD01);

						for (int i = 0; i < files.length; i++) {       
							file = files[i];       

							fr = new FileReader(file);       
							br = new BufferedReader(fr); 
							x=1;

							while ((line = br.readLine()) != null) {
								//System.out.println(line);
								xw.write(x+","+line + System.getProperty("line.separator")) ;//change line
								xw.flush();
							}
						} 

					}  

				}
				catch (FileNotFoundException fnex) {       
					fnex.printStackTrace();       
				} 
				catch (IOException ioex) {       
					ioex.printStackTrace();       
				}
				/*end of copy*/

				setMessage("Collecting Data from SPI 01");
				/* Scanning */
				//File root = new File("z:\\SE300 Output");
				File root = new File("K:\\Spi5");
				if (root != null && root.isDirectory()) {
					try{
						fw = new FileWriter("E:\\public\\Log\\Log\\SPI01.log");
						x=5;
						listRecursively(root, 0);
						fw.close();
					}
					catch(NullPointerException np){
						np.printStackTrace();
					}
					catch(IOException exc){
						exc.printStackTrace();
					}
				}
				else
				{
					//System.out.println("Not a directory: " + root);
					setMessage("Not a directory: " + root);}

				/* Deletes temporary Network Drive before finishing the cycle */
				try
				{            
					String[] cmd = new String[3];

					cmd[0] = "cmd.exe" ;
					cmd[1] = "/C" ;
					cmd[2] = "net use z: /delete /y";


					Runtime rtoff = Runtime.getRuntime();
					//System.out.println("Executing " + cmd[0] + " " + cmd[1] 
					//                  + " " + cmd[2]);
					setMessage("Executing " + cmd[0] + " " + cmd[1] 
					                                             + " " + cmd[2]);
					Process proc = rtoff.exec(cmd);

					// any error message?
					StreamGobbler1 errorGobbler = new 
					StreamGobbler1(proc.getErrorStream(), "ERROR");            

					// any output?
					StreamGobbler1 outputGobbler = new 
					StreamGobbler1(proc.getInputStream(), "OUTPUT");

					// kick them off
					errorGobbler.start();
					outputGobbler.start();

					// any error???
							int exitVal = proc.waitFor();
							setMessage("ExitValue: " + exitVal);
				} catch (Throwable t)
				{
					t.printStackTrace();
				}

Obrigado desde já…

17 Respostas

ViniGodoy

Poxa, vc pelo menos poderia ter dito a linha onde o erro ocorre.

Você espera que a gente depure o programa para você?

Se está dando NullPointerException, só pode significar uma coisa. Uma das suas variáveis está nula. Ponha um breakpoint na linha indicada pela exceção, rode o seu programa, e veja que variável é.

nbluis

Observação.

Pelo amoooooooooooooooooooooorrrrr de deus tira isso.

} catch(NullPointerException np){  
   np.printStackTrace();  
}
J

O erro aponta para esta linha na secçao recursiva

InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));

desculpa aí

ViniGodoy

Agora, olhe acima dessa linha qual foi a última vez que você usou a variável line.
Ela é a única que pode estar nula aí…

ViniGodoy

O erro está bastante evidente, não?

Você inicializa a variável line como null. E depois tenta fazer um split nela nessa linha que vc apontou.

A primeira atribuição a essa variável ocorre só na linha imediamente posterior, dentro do while.

J

Oi… sou mesmo um CAVALO

Você tem razão… eu tenho a variavel String line = null;

antes da InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));

então o que eu tenho que fazer é iniciar a variavel apontando para cada linha do texto de cada ficheiro csv…

mas como posso fazer isto??? estou completamente perdido

O fdir aponta para o folder que contem os subfolders com/e ficheiros com extensão csv

então tenho que inicializar a string line com String line = ?????;

ViniGodoy

Não seria só o caso de paassar essa linha para dentro do while?

J

OUtra vez um CAVALO!!!! isto está mesmo mau!

então apenas tenho que alocar

InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));

dentro do

while ((line = bufferReader.readLine()) != null) {
         if (countline >= startAtLineNo) {
assim????
while ((line = bufferReader.readLine()) != null) {
         if (countline >= startAtLineNo) {

InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));

.....
assim a ela ja está inicializada... certo?
J
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;
					}	
					
					InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));
					
					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();
				}}
:oops:
J

mas assim como coloquei não acontece nada…

como devo fazer para que tenha o resultado que pretendo…

que é… ao ler o texto dentro de cada ficheiro CSV ele primeiro conta quantos F tem… quantas falhas e depois com este INspectionResults44 se a String line tiver 32 elementos ela assigna aquelas variaveis e retira o valor adjacente…

o formato do ficheiro csv é


,SRFF File: F:\MSA070808\240-25-04-B-02-R1.srf
,Panel Name: Panel Description
,Units: Millimeters

,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

,08/07/2008,10:36:07,#11,Module 1,U38,Pad1 ,P,0.146098,0.238000,0.084000,0.140000,W,0.096190,0.184884,0.061628,0.123256,P,0.014871,0.031061,0.008628,0.017256,P,P,-0.044550,-0.000110,17.963709,0.022133,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad2 ,P,0.155322,0.238000,0.084000,0.140000,W,0.094822,0.184884,0.061628,0.123256,P,0.014733,0.031061,0.008628,0.017256,P,P,-0.047370,-0.000470,19.100807,0.094567,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad3 ,P,0.149960,0.238000,0.084000,0.140000,W,0.096209,0.184884,0.061628,0.123256,P,0.016285,0.031061,0.008628,0.017256,P,P,-0.045310,-0.001470,18.270161,0.295775,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad4 ,P,0.157430,0.238000,0.084000,0.140000,W,0.084601,0.184884,0.061628,0.123256,P,0.014648,0.031061,0.008628,0.017256,P,P,-0.041350,-0.006610,16.673388,1.329980,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad5 ,P,0.145546,0.238000,0.084000,0.140000,P,0.824908,1.320000,0.440000,0.880000,P,0.122205,0.221760,0.061600,0.123200,P,P,-0.044290,0.002870,5.536250,0.260909,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad6 ,P,0.152490,0.238000,0.084000,0.140000,W,0.095073,0.184884,0.061628,0.123256,P,0.015789,0.031061,0.008628,0.017256,P,W,-0.051010,-0.010230,20.568548,2.058350,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad7 ,P,0.150482,0.238000,0.084000,0.140000,W,0.092269,0.184884,0.061628,0.123256,P,0.015208,0.031061,0.008628,0.017256,P,P,-0.040420,-0.007430,16.298388,1.494970,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad8 ,P,0.152725,0.238000,0.084000,0.140000,W,0.094822,0.184884,0.061628,0.123256,P,0.015429,0.031061,0.008628,0.017256,P,P,-0.037200,-0.018920,15.000000,3.806841,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U38,Pad9 ,P,0.157542,0.238000,0.084000,0.140000,W,0.092156,0.184884,0.061628,0.123256,P,0.015616,0.031061,0.008628,0.017256,P,P,-0.039430,-0.010590,15.899194,2.130785,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad1 ,P,0.156728,0.238000,0.084000,0.140000,W,0.172095,0.331987,0.110662,0.221325,P,0.027499,0.055774,0.015493,0.030986,P,P,-0.041990,-0.011900,3.661538,6.165933,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad2 ,W,0.177132,0.238000,0.084000,0.140000,W,0.135175,0.286122,0.095374,0.190748,P,0.024294,0.048069,0.013352,0.026705,P,P,-0.043430,-0.022130,7.900750,6.377386,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad3 ,W,0.169345,0.238000,0.084000,0.140000,W,0.137684,0.286122,0.095374,0.190748,P,0.024230,0.048069,0.013352,0.026705,P,P,-0.033930,-0.020030,7.151018,4.982379,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad4 ,P,0.154558,0.238000,0.084000,0.140000,W,0.170382,0.331987,0.110662,0.221325,P,0.027463,0.055774,0.015493,0.030986,P,P,-0.035450,-0.013760,4.233846,5.205580,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad5 ,P,0.156082,0.238000,0.084000,0.140000,W,0.169547,0.331987,0.110662,0.221325,P,0.027541,0.055774,0.015493,0.030986,P,P,-0.021930,-0.011020,3.390769,3.220264,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad6 ,W,0.176801,0.238000,0.084000,0.140000,W,0.137471,0.286122,0.095374,0.190748,P,0.025290,0.048069,0.013352,0.026705,P,P,-0.022060,-0.021270,7.593717,3.239354,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad7 ,W,0.190212,0.238000,0.084000,0.140000,W,0.126302,0.286122,0.095374,0.190748,P,0.025167,0.048069,0.013352,0.026705,P,P,-0.007590,-0.030400,10.853267,1.114537,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R11,Pad8 ,P,0.163126,0.238000,0.084000,0.140000,W,0.171153,0.331987,0.110662,0.221325,P,0.028842,0.055774,0.015493,0.030986,P,P,-0.033610,-0.019820,6.098462,4.935389,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad1 ,P,0.148519,0.238000,0.084000,0.140000,W,0.162959,0.331987,0.110662,0.221325,P,0.025168,0.055774,0.015493,0.030986,P,P,-0.018300,-0.002100,0.646154,2.687225,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad2 ,P,0.165713,0.238000,0.084000,0.140000,W,0.124771,0.286122,0.095374,0.190748,P,0.021779,0.048069,0.013352,0.026705,P,P,-0.020540,-0.015150,5.408782,3.016153,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad3 ,W,0.188443,0.238000,0.084000,0.140000,W,0.133568,0.286122,0.095374,0.190748,P,0.026102,0.048069,0.013352,0.026705,P,P,-0.044480,-0.008700,3.106034,6.531571,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad4 ,W,0.171132,0.238000,0.084000,0.140000,W,0.174648,0.331987,0.110662,0.221325,P,0.031280,0.055774,0.015493,0.030986,P,P,-0.036860,-0.015600,4.800000,5.412629,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad5 ,P,0.153381,0.238000,0.084000,0.140000,W,0.166190,0.331987,0.110662,0.221325,P,0.026019,0.055774,0.015493,0.030986,P,P,-0.022360,-0.002800,0.861538,3.283407,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad6 ,W,0.181782,0.238000,0.084000,0.140000,W,0.114832,0.286122,0.095374,0.190748,P,0.021701,0.048069,0.013352,0.026705,P,P,0.011460,-0.016450,5.872902,1.682819,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad7 ,W,0.201359,0.238000,0.084000,0.140000,W,0.121716,0.286122,0.095374,0.190748,P,0.025405,0.048069,0.013352,0.026705,P,P,-0.000440,-0.010500,3.748661,0.064611,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R32,Pad8 ,W,0.173068,0.238000,0.084000,0.140000,W,0.166021,0.331987,0.110662,0.221325,P,0.030400,0.055774,0.015493,0.030986,P,P,-0.020840,-0.017000,5.230769,3.060206,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad1 ,W,0.175997,0.238000,0.084000,0.140000,W,0.158221,0.331987,0.110662,0.221325,P,0.029017,0.055774,0.015493,0.030986,P,P,-0.030975,-0.006110,9.530769,0.897210,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad2 ,P,0.167120,0.238000,0.084000,0.140000,W,0.138400,0.286122,0.095374,0.190748,P,0.025751,0.048069,0.013352,0.026705,P,P,-0.043328,0.012200,15.468761,1.791483,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad3 ,P,0.159482,0.238000,0.084000,0.140000,W,0.142761,0.286122,0.095374,0.190748,P,0.024399,0.048069,0.013352,0.026705,P,P,-0.048245,-0.008000,17.224205,1.174743,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad4 ,W,0.173304,0.238000,0.084000,0.140000,W,0.153365,0.331987,0.110662,0.221325,P,0.028820,0.055774,0.015493,0.030986,P,P,-0.034827,-0.003620,10.716000,0.531571,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad5 ,W,0.173142,0.238000,0.084000,0.140000,W,0.161666,0.331987,0.110662,0.221325,P,0.028880,0.055774,0.015493,0.030986,P,P,-0.035614,0.004670,10.958154,0.685756,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad6 ,P,0.151596,0.238000,0.084000,0.140000,W,0.146651,0.286122,0.095374,0.190748,P,0.024247,0.048069,0.013352,0.026705,P,P,-0.043547,0.018050,15.546947,2.650514,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad7 ,P,0.164801,0.238000,0.084000,0.140000,W,0.136279,0.286122,0.095374,0.190748,P,0.024022,0.048069,0.013352,0.026705,P,P,-0.044511,0.005320,15.891110,0.781204,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R37,Pad8 ,W,0.188923,0.238000,0.084000,0.140000,W,0.140521,0.331987,0.110662,0.221325,P,0.028738,0.055774,0.015493,0.030986,P,P,-0.032976,0.011340,10.146461,1.665198,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad1 ,W,0.169597,0.238000,0.084000,0.140000,W,0.157255,0.331987,0.110662,0.221325,P,0.027730,0.055774,0.015493,0.030986,P,P,-0.011410,-0.014700,3.510769,2.158590,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad2 ,P,0.159641,0.238000,0.084000,0.140000,W,0.147504,0.286122,0.095374,0.190748,P,0.025464,0.048069,0.013352,0.026705,P,P,-0.034650,-0.009700,12.370582,1.424376,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad3 ,P,0.165509,0.238000,0.084000,0.140000,W,0.139002,0.286122,0.095374,0.190748,P,0.024287,0.048069,0.013352,0.026705,P,P,-0.034344,0.003000,12.261335,0.440529,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad4 ,W,0.172483,0.238000,0.084000,0.140000,W,0.153064,0.331987,0.110662,0.221325,P,0.026814,0.055774,0.015493,0.030986,P,P,-0.037531,-0.012800,11.548000,1.879589,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad5 ,W,0.173113,0.238000,0.084000,0.140000,W,0.170614,0.331987,0.110662,0.221325,P,0.029711,0.055774,0.015493,0.030986,P,P,-0.021222,-0.005900,6.529846,0.866373,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad6 ,P,0.165331,0.238000,0.084000,0.140000,P,0.159175,0.286122,0.095374,0.190748,P,0.027813,0.048069,0.013352,0.026705,P,P,-0.040248,0.007300,14.369154,1.071953,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad7 ,W,0.170863,0.238000,0.084000,0.140000,W,0.149393,0.286122,0.095374,0.190748,P,0.026784,0.048069,0.013352,0.026705,P,P,-0.039559,0.010400,14.123170,1.527166,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R707,Pad8 ,P,0.163061,0.238000,0.084000,0.140000,W,0.174855,0.331987,0.110662,0.221325,P,0.029264,0.055774,0.015493,0.030986,P,P,-0.027853,-0.000300,8.570154,0.044053,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad1 ,W,0.179906,0.238000,0.084000,0.140000,W,0.169384,0.331987,0.110662,0.221325,P,0.032103,0.055774,0.015493,0.030986,P,P,-0.036360,-0.019180,11.187693,2.816446,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad2 ,P,0.167627,0.238000,0.084000,0.140000,W,0.145164,0.286122,0.095374,0.190748,P,0.026043,0.048069,0.013352,0.026705,P,P,-0.037351,-0.002980,13.334881,0.437592,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad3 ,W,0.168289,0.238000,0.084000,0.140000,W,0.145471,0.286122,0.095374,0.190748,P,0.026718,0.048069,0.013352,0.026705,P,P,-0.038853,-0.009810,13.871118,1.440529,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad4 ,W,0.178395,0.238000,0.084000,0.140000,W,0.164069,0.331987,0.110662,0.221325,P,0.030528,0.055774,0.015493,0.030986,P,P,-0.037227,-0.004680,11.454461,0.687225,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad5 ,W,0.182430,0.238000,0.084000,0.140000,W,0.160342,0.331987,0.110662,0.221325,P,0.031180,0.055774,0.015493,0.030986,P,P,-0.035280,-0.020380,10.855385,2.992658,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad6 ,W,0.171215,0.238000,0.084000,0.140000,W,0.142503,0.286122,0.095374,0.190748,P,0.027250,0.048069,0.013352,0.026705,P,P,-0.033680,-0.014640,12.024277,2.149780,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad7 ,P,0.165889,0.238000,0.084000,0.140000,W,0.145942,0.286122,0.095374,0.190748,P,0.025961,0.048069,0.013352,0.026705,P,P,-0.048019,0.005530,17.143520,0.812041,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R8,Pad8 ,W,0.170006,0.238000,0.084000,0.140000,W,0.162701,0.331987,0.110662,0.221325,P,0.029205,0.055774,0.015493,0.030986,P,P,-0.044827,0.004490,13.792923,0.659325,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad1 ,W,0.188826,0.238000,0.084000,0.140000,W,0.157192,0.331987,0.110662,0.221325,P,0.030608,0.055774,0.015493,0.030986,P,P,-0.014600,-0.014600,4.492308,2.143906,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad2 ,W,0.170884,0.238000,0.084000,0.140000,P,0.152932,0.286122,0.095374,0.190748,P,0.028231,0.048069,0.013352,0.026705,P,P,-0.033136,-0.008500,11.830061,1.248164,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad3 ,P,0.163953,0.238000,0.084000,0.140000,P,0.155768,0.286122,0.095374,0.190748,P,0.027010,0.048069,0.013352,0.026705,P,P,-0.041687,0.002900,14.882899,0.425844,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad4 ,P,0.160897,0.238000,0.084000,0.140000,W,0.169635,0.331987,0.110662,0.221325,P,0.027908,0.055774,0.015493,0.030986,P,P,-0.027878,0.000400,8.577847,0.058737,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad5 ,P,0.165853,0.238000,0.084000,0.140000,P,0.197770,0.331987,0.110662,0.221325,P,0.033597,0.055774,0.015493,0.030986,P,P,-0.038670,0.002300,11.898461,0.337739,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad6 ,P,0.166512,0.238000,0.084000,0.140000,P,0.176205,0.286122,0.095374,0.190748,P,0.030008,0.048069,0.013352,0.026705,P,P,-0.041238,-0.000400,14.722599,0.058737,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad7 ,P,0.167219,0.238000,0.084000,0.140000,P,0.167947,0.286122,0.095374,0.190748,P,0.028929,0.048069,0.013352,0.026705,P,P,-0.042367,0.014500,15.125669,2.129222,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,R706,Pad8 ,P,0.166342,0.238000,0.084000,0.140000,P,0.191176,0.331987,0.110662,0.221325,P,0.032790,0.055774,0.015493,0.030986,P,P,-0.032292,-0.009100,9.936000,1.336270,40.000000,40.000000,P,0.000000,0.350000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad1 ,P,0.143657,0.238000,0.084000,0.140000,P,0.131535,0.238565,0.079522,0.159043,P,0.019427,0.040079,0.011133,0.022266,P,P,-0.058984,0.006670,13.107555,1.482222,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad2 ,P,0.140606,0.238000,0.084000,0.140000,P,0.131767,0.238565,0.079522,0.159043,P,0.019426,0.040079,0.011133,0.022266,P,P,-0.054767,0.007470,12.170444,1.660000,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad3 ,P,0.138779,0.238000,0.084000,0.140000,P,0.128636,0.238565,0.079522,0.159043,P,0.018208,0.040079,0.011133,0.022266,P,P,-0.055699,0.017970,12.377556,3.993333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad4 ,P,0.152724,0.238000,0.084000,0.140000,W,0.124771,0.238565,0.079522,0.159043,P,0.019146,0.040079,0.011133,0.022266,P,P,-0.051345,0.016510,11.410000,3.668889,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad5 ,P,0.138278,0.238000,0.084000,0.140000,P,0.132709,0.238565,0.079522,0.159043,P,0.019014,0.040079,0.011133,0.022266,P,P,-0.046748,0.014180,10.388445,3.151111,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad6 ,P,0.141585,0.238000,0.084000,0.140000,P,0.130952,0.238565,0.079522,0.159043,P,0.018891,0.040079,0.011133,0.022266,P,P,-0.045189,0.010910,10.042000,2.424444,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad7 ,P,0.157589,0.238000,0.084000,0.140000,P,0.131178,0.238565,0.079522,0.159043,P,0.021140,0.040079,0.011133,0.022266,P,P,-0.059660,0.011380,13.257778,2.528889,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad8 ,P,0.151409,0.238000,0.084000,0.140000,P,0.128793,0.238565,0.079522,0.159043,P,0.019583,0.040079,0.011133,0.022266,P,P,-0.055135,0.010430,12.252222,2.317778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad9 ,P,0.147126,0.238000,0.084000,0.140000,W,0.126359,0.238565,0.079522,0.159043,P,0.019068,0.040079,0.011133,0.022266,P,P,-0.050606,0.022600,11.245778,5.022222,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad10 ,P,0.150723,0.238000,0.084000,0.140000,P,0.127764,0.238565,0.079522,0.159043,P,0.019516,0.040079,0.011133,0.022266,P,P,-0.052427,0.022400,11.650444,4.977778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad11 ,P,0.147838,0.238000,0.084000,0.140000,W,0.125625,0.238565,0.079522,0.159043,P,0.019184,0.040079,0.011133,0.022266,P,P,-0.047183,0.015660,10.485111,3.480000,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad12 ,P,0.151460,0.238000,0.084000,0.140000,W,0.124953,0.238565,0.079522,0.159043,P,0.019815,0.040079,0.011133,0.022266,P,P,-0.042343,0.008220,9.409555,1.826667,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad13 ,P,0.155374,0.238000,0.084000,0.140000,W,0.121891,0.238565,0.079522,0.159043,P,0.020172,0.040079,0.011133,0.022266,P,P,-0.056367,0.011810,12.526000,2.624444,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad14 ,P,0.159908,0.238000,0.084000,0.140000,W,0.123002,0.238565,0.079522,0.159043,P,0.020786,0.040079,0.011133,0.022266,P,P,-0.050077,0.012240,11.128222,2.720000,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad15 ,P,0.149750,0.238000,0.084000,0.140000,P,0.130927,0.238565,0.079522,0.159043,P,0.020297,0.040079,0.011133,0.022266,P,P,-0.049952,0.011790,11.100445,2.620000,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad16 ,P,0.155657,0.238000,0.084000,0.140000,P,0.129935,0.238565,0.079522,0.159043,P,0.020768,0.040079,0.011133,0.022266,P,P,-0.053739,0.012930,11.942000,2.873333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad17 ,P,0.150983,0.238000,0.084000,0.140000,P,0.134039,0.238565,0.079522,0.159043,P,0.020459,0.040079,0.011133,0.022266,P,P,-0.053840,0.017000,11.964444,3.777778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad18 ,P,0.151699,0.238000,0.084000,0.140000,P,0.133248,0.238565,0.079522,0.159043,P,0.021599,0.040079,0.011133,0.022266,P,P,-0.040975,0.006180,9.105556,1.373333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad19 ,P,0.163506,0.238000,0.084000,0.140000,W,0.126817,0.238565,0.079522,0.159043,P,0.021493,0.040079,0.011133,0.022266,P,P,-0.054616,0.012390,12.136889,2.753333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad20 ,P,0.147814,0.238000,0.084000,0.140000,P,0.131102,0.238565,0.079522,0.159043,P,0.020646,0.040079,0.011133,0.022266,P,P,-0.047005,0.019440,10.445556,4.320000,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad21 ,P,0.153069,0.238000,0.084000,0.140000,W,0.126415,0.238565,0.079522,0.159043,P,0.020352,0.040079,0.011133,0.022266,P,P,-0.047168,0.012500,10.481778,2.777778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad22 ,P,0.159714,0.238000,0.084000,0.140000,W,0.124627,0.238565,0.079522,0.159043,P,0.020580,0.040079,0.011133,0.022266,P,P,-0.051005,0.016430,11.334444,3.651111,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad23 ,P,0.155264,0.238000,0.084000,0.140000,P,0.127764,0.238565,0.079522,0.159043,P,0.020594,0.040079,0.011133,0.022266,P,P,-0.048685,0.020150,10.818889,4.477778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad24 ,P,0.160284,0.238000,0.084000,0.140000,P,0.135250,0.238565,0.079522,0.159043,P,0.021976,0.040079,0.011133,0.022266,P,P,-0.043952,0.022800,9.767111,5.066667,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad25 ,P,0.152703,0.238000,0.084000,0.140000,P,0.132050,0.238565,0.079522,0.159043,P,0.021192,0.040079,0.011133,0.022266,P,P,-0.055832,0.019250,12.407111,4.277778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad26 ,P,0.145065,0.238000,0.084000,0.140000,P,0.135394,0.238565,0.079522,0.159043,P,0.020719,0.040079,0.011133,0.022266,P,P,-0.057990,0.014210,12.886666,3.157778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad27 ,P,0.153265,0.238000,0.084000,0.140000,P,0.128392,0.238565,0.079522,0.159043,P,0.020201,0.040079,0.011133,0.022266,P,P,-0.046495,0.004440,10.332222,0.986667,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad28 ,P,0.148896,0.238000,0.084000,0.140000,P,0.130149,0.238565,0.079522,0.159043,P,0.020404,0.040079,0.011133,0.022266,P,P,-0.048392,0.011510,10.753778,2.557778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad29 ,P,0.155457,0.238000,0.084000,0.140000,P,0.133248,0.238565,0.079522,0.159043,P,0.021524,0.040079,0.011133,0.022266,P,P,-0.052174,0.011460,11.594222,2.546667,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad30 ,P,0.151930,0.238000,0.084000,0.140000,P,0.137735,0.238565,0.079522,0.159043,P,0.021820,0.040079,0.011133,0.022266,P,P,-0.047130,0.018700,10.473333,4.155556,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad31 ,P,0.159183,0.238000,0.084000,0.140000,W,0.127130,0.238565,0.079522,0.159043,P,0.021456,0.040079,0.011133,0.022266,P,P,-0.052673,0.013750,11.705112,3.055556,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad32 ,P,0.164274,0.238000,0.084000,0.140000,W,0.126660,0.238565,0.079522,0.159043,P,0.022081,0.040079,0.011133,0.022266,P,P,-0.052500,0.004490,11.666667,0.997778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad33 ,P,0.154841,0.238000,0.084000,0.140000,W,0.126534,0.238565,0.079522,0.159043,P,0.020400,0.040079,0.011133,0.022266,P,P,-0.049556,0.006990,11.012444,1.553333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad34 ,P,0.161080,0.238000,0.084000,0.140000,W,0.126277,0.238565,0.079522,0.159043,P,0.021314,0.040079,0.011133,0.022266,P,P,-0.051161,0.009150,11.369111,2.033333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad35 ,P,0.163472,0.238000,0.084000,0.140000,P,0.131397,0.238565,0.079522,0.159043,P,0.022426,0.040079,0.011133,0.022266,P,P,-0.041658,0.015740,9.257334,3.497778,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad36 ,P,0.159744,0.238000,0.084000,0.140000,W,0.127049,0.238565,0.079522,0.159043,P,0.021076,0.040079,0.011133,0.022266,P,P,-0.048704,0.012270,10.823112,2.726667,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad37 ,P,0.153656,0.238000,0.084000,0.140000,P,0.133738,0.238565,0.079522,0.159043,P,0.021357,0.040079,0.011133,0.022266,P,P,-0.051547,0.009510,11.454889,2.113333,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad38 ,P,0.155675,0.238000,0.084000,0.140000,P,0.135651,0.238565,0.079522,0.159043,P,0.021487,0.040079,0.011133,0.022266,P,P,-0.053681,0.008370,11.929111,1.860000,40.000000,40.000000,P,0.000000,0.500000
,08/07/2008,10:36:07,#11,Module 1,U35,Pad39 ,P,0.154041,0.238000,0.084000,0.140000,P,0.130475,0.238565,0.079522,0.159043,P,0.021382,0.040079,0.011133,0.022266,P,P,-0.048236,0.008430,10.719111,1.873333,40.000000,40.000000,P,0.000000,0.500000

depois de ler este ficheiro vai ler o seguinte ficheiro csv… e assim por diante…

J

Na teoria isto deveria funcionar....

/* .........................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,";
		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
			
			while ((line = bufferReader.readLine()) != null) {
				if (countline >= startAtLineNo) {
					InspectionResults44 inspectionResults = new InspectionResults44(line.split(","));
					
					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(HEIGHT_AVG_RESULT)){
							Height = inspectionResults.getAdjacentValue(HEIGHT_AVG_RESULT);
							countHeight++;
						}
						if(inspectionResults.hasFailed(AREA_AVG_RESULT)){
							Area = inspectionResults.getAdjacentValue(AREA_AVG_RESULT);
							countArea++;
						}
						if(inspectionResults.hasFailed(VOLUME_AVG_RESULT)){
							Area = inspectionResults.getAdjacentValue(VOLUME_AVG_RESULT);
							countVolume++;
						}
						if(inspectionResults.hasFailed(REG_OFF_RESULT)){
							Area = inspectionResults.getAdjacentValue(REG_OFF_RESULT);
							countRegOffset++;
						}
						if(inspectionResults.hasFailed(BRIDGE_LEN_RESULT)){
							Area = inspectionResults.getAdjacentValue(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);
			}}}

a questão é que não consigo fazer com que no caso de encontrar um F eu consiga retirar adicionar à quantidade de cada erro

ViniGodoy

É melhor você parar, reorganizar seu código e entender o que você mesmo está fazendo.

Aparentemente, você já se perdeu dentro do seu próprio programa faz tempo…

J

não! o problema que surgiu é estive parado muitos meses por problemas de saúde e agora estou tentando pegar de novo o que deixei para trás…

o meu Java tb nunca foi bom… No entanto o meu Muito Obrigado!

Saudações

J

Eu já percebi que o problema se centra nestes 2 whiles…

o scanner funciona bem mas o seguinte não roda…

J

[quote]
while(scan.hasNextLine())
{
if(scan.nextLine().contains(F))
count++;
}

// fileRead.close();
// bufferReader.close();//___________________________original

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 {
InspectionResults32 inspectionResults = new InspectionResults32(line.split(","));
if(inspectionResults.hasFailed(HEIGHT_AVG_RESULT))
//Height = inspectionResults.getAdjacentValue(InspectionResults44.HEIGHT_AVG_RESULT);
countHeight++;
if(inspectionResults.hasFailed(AREA_AVG_RESULT))
//Area = inspectionResults.getAdjacentValue(InspectionResults44.AREA_AVG_RESULT);
countArea++;
if(inspectionResults.hasFailed(VOLUME_AVG_RESULT))
//Area = inspectionResults.getAdjacentValue(InspectionResults44.VOLUME_AVG_RESULT);
countVolume++;
if(inspectionResults.hasFailed(REG_OFF_RESULT))
//Area = inspectionResults.getAdjacentValue(InspectionResults44.REG_OFF_RESULT);
countRegOffset++;
if(inspectionResults.hasFailed(BRIDGE_LEN_RESULT))
//Area = inspectionResults.getAdjacentValue(InspectionResults44.BRIDGE_LEN_RESULT);
countBridging++;
}
catch (Exception e) {
e.printStackTrace();
}
// fileRead.close();
// bufferReader.close();
}}[code]

ViniGodoy

Tente separar seu programa em métodos menores, criar classes para dados que andem comumente juntos, em resumo, tente refatorar o código.

Fica realmente difícil entender o problema quando seu código tem centenas de linhas num único método.

J

OI…

O meu problema centra-se com o facto de não conseguir incrementar estas varaiveis…try { InspectionResults32 inspectionResults = new InspectionResults32(line.split(",")); if(inspectionResults.hasFailed(HEIGHT_AVG_RESULT)) //Height = inspectionResults.getAdjacentValue(InspectionResults44.HEIGHT_AVG_RESULT); countHeight++; if(inspectionResults.hasFailed(AREA_AVG_RESULT)) //Area = inspectionResults.getAdjacentValue(InspectionResults44.AREA_AVG_RESULT); countArea++; if(inspectionResults.hasFailed(VOLUME_AVG_RESULT)) //Area = inspectionResults.getAdjacentValue(InspectionResults44.VOLUME_AVG_RESULT); countVolume++; if(inspectionResults.hasFailed(REG_OFF_RESULT)) //Area = inspectionResults.getAdjacentValue(InspectionResults44.REG_OFF_RESULT); countRegOffset++; if(inspectionResults.hasFailed(BRIDGE_LEN_RESULT)) //Area = inspectionResults.getAdjacentValue(InspectionResults44.BRIDGE_LEN_RESULT); countBridging++; }

Consigo fazer funcionar o primeiro While… em que obtenho a contagem dos F… com a variavel Count dentro do scanner…

mas no segundo while não estou conseguindo…

Valeu

Criado 14 de agosto de 2008
Ultima resposta 17 de ago. de 2008
Respostas 17
Participantes 3