Comment lire la ligne exact d'un fichier?
Bonjour à tous !
Voilà je voudrais un coup de main ! :)
Je voudrais afficher la 1ère ligne de ce fichier :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
Processor : ARMv7 Processor rev 2 (v7l)
BogoMIPS : 398.60
Features : swp half thumb fastmult vfp edsp neon vfpv3
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc08
CPU revision : 2
Hardware : SMDKC110
Revision : 0030
Serial : 3330d9a1419900ec |
Le chemin de ce fichier est : /proc/cpuinfo
Voici mon code :
Code:
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
|
static public long getProcessorInfo(){
try
{
File file = new File("/proc/cpuinfo");
FileReader reader = new FileReader(file);
BufferedReader buff = new BufferedReader(reader);
String line;
String name;
String value;
do
{
try
{
line = buff.readLine();
name = line.substring(0, line.indexOf(":"));
value = line.substring(line.indexOf(":")+1, line.lastIndexOf(" "));
if (name.equals("Processor"))
{
processor = Integer.valueOf(value.substring(value.lastIndexOf(" ")+1, value.length()));
break;
}
}
catch (Exception e)
{
break;
}
}
while(line != null);
buff.close();
reader.close();
}
catch (Exception e)
{
}
return processor;
} |
Le résultat affiché est 0! 8O