Skip to content

Commit 0a0ceca

Browse files
committed
Close the buffered source reader
1 parent 5c03146 commit 0a0ceca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

utilcode/src/main/java/com/blankj/utilcode/utils/DeviceUtils.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ public static String getMacAddress(Context context) {
4848
*/
4949
public static String getMacAddress() {
5050
String macAddress = null;
51+
LineNumberReader reader = null;
5152
try {
5253
Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address");
5354
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
54-
LineNumberReader reader = new LineNumberReader(ir);
55+
reader = new LineNumberReader(ir);
5556
macAddress = reader.readLine().replace(":", "");
5657
} catch (IOException ex) {
5758
ex.printStackTrace();
59+
} finally {
60+
try {
61+
if (reader != null) reader.close();
62+
} catch (IOException e) {
63+
e.printStackTrace();
64+
}
5865
}
5966
return macAddress == null ? "" : macAddress;
6067
}

0 commit comments

Comments
 (0)