1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
protected void validateFileStructure(File file) throws IOException
{
LineIterator lineIterator = FileUtils.lineIterator(file);
Set<String> idndocs = new HashSet<String>();
int i= 0;
int j=0;//compteur
LineNumberReader lnr=new LineNumberReader(new FileReader(file));
try{
String ligneLue;
//creation du flux
try{
List<String> tabCodeCaisse=Arrays.asList(new String[]{"16275","18025","15135","13135","18715","14445","14505","43199","13335","17515","12579",
"11425","11315","13485","18315","12135","13825","14265","16705","12128","19019"});
List<String> tabCodeTypeAttr=Arrays.asList(new String[]{"1","2","3","4","5","6","7","8","9","10","11"});
while((ligneLue=lnr.readLine())!=null)//parcours des lignes
{ String[] tabLigneLue=ligneLue.split(";");//split la ligne lue
if (tabLigneLue.length>0)
{
String codeCaisse=tabLigneLue[0];
if(tabCodeCaisse.contains(codeCaisse))
{
String CodeTpeAttr=tabLigneLue[1];
if(tabCodeTypeAttr.contains(CodeTpeAttr))
LOG.info("");
else
{LOG.info("Code type attributaire "+ CodeTpeAttr+ " non valide. Vérifier la saisie");
//J AIMERAI SUPPRIMER OU IGNORER LA LIGNE ICI
// IDEALEMENT: ligneLue.delete()}
}
else
LOG.info("Code Caisse "+ codeCaisse + " inexistant." + " Verifiez la saisie.");
}
}//fin du while
}//fin du try
finally
{
lnr.close();//libération des ressources**/
}
} catch (IOException ioe) {
// erreur de fermeture des flux
System.out.println("Erreur --" + ioe.toString());
}
} |
Partager