Recuperer des phrases d'un fichier texte JAVA

Résolu
cs_gafsa Messages postés 2 Date d'inscription vendredi 4 mai 2007 Statut Membre Dernière intervention 5 décembre 2010 - 15 juin 2010 à 12:56
cs_sanyouch Messages postés 8 Date d'inscription dimanche 16 mai 2010 Statut Membre Dernière intervention 22 juin 2013 - 23 avril 2013 à 12:51
Bonjour tout le monde,
j'ai un fichier texte qui contient des information pour mon pfe
mon but c je vx extraire c donné et les stocké ds des variable puis ds BD

voici mon fichier texte :


. Warning found on port general/icmp 


     
[b]    The remote host answers to an ICMP timestamp 
    request. This allows an attacker to know the 
    date which is set on your machine.  
     
    This may help him to defeat all your  
    time based authentication protocols/b. 
     
    Solution : filter out the ICMP timestamp 
    requests (13), and the outgoing ICMP  
    timestamp replies (14). 
     
    Risk factor : Low
    CVE : CAN-1999-0524 

 . Warning found on port general/tcp 


     
    The remote host uses non-random IP IDs, that is, it is 
    possible to predict the next value of the ip_id field of 
    the ip packets sent by this host. 
     
    An attacker may use this feature to determine if the remote 
    host sent a packet in reply to another request. This may be 
    used for portscanning and other things. 
     
    Solution : Contact your vendor for a patch 
    Risk factor : Low 




ainsi voisi mon code java



import java.io.*;  //pour les classes io 
import java.util.*; 

/** 
 * @author Administrateur 
 * 
 */ 
public class Lecture_File { 
  
 public static void main(String[] args){ 

 String partie1, partie2, partie3, ch=""; 
 String fichier ="fichier.txt"; 
 String chaine="" ; 
  
 try{ 
  InputStream ips=new FileInputStream(fichier);  
  InputStreamReader ipsr=new InputStreamReader(ips); 
  BufferedReader br=new BufferedReader(ipsr); 
  String ligne; 
  while ((ligne=br.readLine())!=null){ 
    
   ch=""; 
   StringTokenizer st = new StringTokenizer(ligne,"solution"); 
   while (st.hasMoreTokens()) { 
        //System.out.println(st.nextToken()); 
        ch+=st.nextToken(); 
       } 
   System.out.println(ch); 
   chaine+=ligne+"\n"; 
  } 
   

   
   
   
   
  br.close();  
 }   
 catch (Exception e){ 
  System.out.println(e.toString()); 
 } 

  
  
  
 } 

} 


les variable à extraire sont en gras aussi les info ds la second paragraphe
et merci d'avance




2 réponses

johnjjj Messages postés 120 Date d'inscription dimanche 4 avril 2010 Statut Membre Dernière intervention 24 septembre 2012
16 juin 2010 à 03:18
bonjour dans votre code il va affiche dans le premiere ligne

. Warg fd pr geera/cmp

mais il faut qu'il affiche . Warning found on port general/icmp

pour coupez une chaine tu peut utiliser la methode split


et pour ajouter dans une base donnes vous pouvez utiliser requete sql insert
3
cs_sanyouch Messages postés 8 Date d'inscription dimanche 16 mai 2010 Statut Membre Dernière intervention 22 juin 2013 1
23 avril 2013 à 12:51
Bonjour tout le monde,
j'ai besoin d'un code qui fait l'extraction des méthodes et des attributs d'une classe java.
Merci d'avance
0
Rejoignez-nous
A voir également