Skip to content

Commit a6a3dca

Browse files
committed
add IntLogger.
update mac fuctions.
1 parent 527bb48 commit a6a3dca

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

src/com/dataBean/DataBeans.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,11 @@ public static IntDataBean getAddDataBean(List<IntDataTuple> sd,String name){
8888
System.out.println("Current IP address : " + ip.getHostAddress());
8989
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
9090
byte[] mac = network.getHardwareAddress();
91-
String s="";
92-
for(byte i:mac){
93-
s+=Byte.toString(i);
94-
/*if(i<=9)
95-
s+=i;
96-
else if(i==10)
97-
s+='A';
98-
else if(i==11)
99-
s+='B';
100-
else if(i==12)
101-
s+='C';
102-
else if(i==13)
103-
s+='D';
104-
else if(i==14)
105-
s+='E';
106-
else if(i==15)
107-
s+='F';*/
91+
StringBuilder sb = new StringBuilder();
92+
for (int i = 0; i < mac.length; i++) {
93+
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
10894
}
109-
return new DataBean(sd,name,LocalDateTime.now(),ip.getHostAddress(),s);
95+
return new DataBean(sd,name,LocalDateTime.now(),ip.getHostAddress(),sb.toString());
11096
} catch(Exception ex) {
11197
return null;
11298
}

src/ser/logger/IntLogger.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2017 Neel Patel.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package ser.logger;
17+
18+
import com.dataBean.IntDataBean;
19+
20+
/**
21+
*
22+
* @author Neel Patel
23+
*/
24+
public interface IntLogger {
25+
boolean log(IntDataBean db);
26+
}

src/ser/logger/MyLog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @author Neel Patel
2929
*/
30-
public class MyLog {
30+
public class MyLog implements IntLogger{
3131
private Path p;
3232
private static final String dtf="yyMMdd";
3333

@@ -39,6 +39,7 @@ public MyLog(Path dir){
3939
p=dir;
4040
}
4141

42+
@Override
4243
public synchronized boolean log(IntDataBean db){
4344
try{
4445
LocalDate date=db.getTime().toLocalDate();

0 commit comments

Comments
 (0)