File tree 1 file changed +8
-1
lines changed
utilcode/src/main/java/com/blankj/utilcode/utils
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,20 @@ public static String getMacAddress(Context context) {
48
48
*/
49
49
public static String getMacAddress () {
50
50
String macAddress = null ;
51
+ LineNumberReader reader = null ;
51
52
try {
52
53
Process pp = Runtime .getRuntime ().exec ("cat /sys/class/net/wlan0/address" );
53
54
InputStreamReader ir = new InputStreamReader (pp .getInputStream ());
54
- LineNumberReader reader = new LineNumberReader (ir );
55
+ reader = new LineNumberReader (ir );
55
56
macAddress = reader .readLine ().replace (":" , "" );
56
57
} catch (IOException ex ) {
57
58
ex .printStackTrace ();
59
+ } finally {
60
+ try {
61
+ if (reader != null ) reader .close ();
62
+ } catch (IOException e ) {
63
+ e .printStackTrace ();
64
+ }
58
65
}
59
66
return macAddress == null ? "" : macAddress ;
60
67
}
You can’t perform that action at this time.
0 commit comments