Reputation: 1656
I want to get Linux version using this code:
public void getSystemVersion()
{
File f = new File("/etc/");
File[] allReleaseFiles = f.listFiles(new FilenameFilter()
{
@Override
public boolean accept(File dir, String name)
{
System.out.println("System Verison : " + name.endsWith("-release"));
return name.endsWith("-release");
}
});
}
But this is the output that I get:
.......
System Verison : false
System Verison : false
System Verison : false
System Verison : false
System Verison : false
System Verison : false
System Verison : false
........
Can you help me to find the problem? Also how I can do this using Java 8 code?
Upvotes: 0
Views: 116
Reputation: 774
Try to parse /proc/version
. It's the same as calling uname -r
. At least you don't have to mess with processes.
Upvotes: 1