String os = System.getProperty( "os.name" ); if ( os != null && os.startsWith( "Windows" ) ) { try { String command = "cmd.exe /c netsh interface show interface|more +3"; Process p = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(),"GBK")); String line; while ((line = br.readLine()) != null) { if (!line.contains("VMware") && !line.contains("WLAN") && line.length() > 0) { int i = line.lastIndexOf(" "); String name = line.substring(i).trim(); //输出网络连接名 System.out.println(name); break; } } } catch (IOException e) { e.printStackTrace(); } }