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 57 58 59 60 61 62 63 64 65 66
| import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class extraction
{
public static void main (String[] args) throws IOException
{
System.out.println("UWS");
BufferedReader in = new BufferedReader(new FileReader("C:/Users/hp/Desktop/stage/FBL2.txt"));
String line;
String tab[] = null;
int j=0;
int k=0;
String t=null;
while ((line = in.readLine()) != null)
{
String[] result = line.split("/");
for (int i=0; i<result.length; i++){
if(j==1 && (i==1)){
System.out.print(result[i]+"/");
t=result[i];
k++;
}
else if(j==1 && (i==2)){
Pattern p = Pattern.compile("\\d");
Matcher m = p.matcher(result[i]);
while(m.find())
System.out.print(m.group());
System.out.println("."+result[i+1]+".FINAL");
t=result[i];
k++;
}
else if(j==2){
System.out.print(result[i]+"/");
j++;
}
else if(line.startsWith("147")&&i==1){
int somme=0;
String Str = new String(t);
int indexK=Str.indexOf("K");
int indexDG=Str.indexOf("DG");
int n1= Integer.parseInt(Str.substring(indexK+1, indexDG));
System.out.println(Str.substring(indexK+1, indexK+2) );
}
}
j++;
}
in.close();
}
} |
Partager