Malformed byte sequence: Invalid byte 2 of 3-byte UTF-8 sequence
Solution:
Use the UTF-8 encoding.
Possible Errors:
1.Might be you are using default-encoding while forming a string...
Thursday, 20 October 2011
How to add lessthan or greaterThan characters in XSLT
using CDATA we can transform any character--
like this below examples:
<![CDATA[<]]>
<![CDATA[>]]>
<![CDATA[</]]>
<![CDATA[write anything here]]>
Fetch MAC address of the Machine
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
public class MacAddress
{
private String getMacAddress()
{
StringBuffer macAddress=new StringBuffer();
try {
InetAddress address = InetAddress.getLocalHost();
//InetAddress address = InetAddress.getByName("192.75.48.67");
/*
* Get NetworkInterface for the current host and then read the
* hardware address.
*/
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
if (ni != null) {
byte[] mac = ni.getHardwareAddress();
if (mac != null) {
/*
* Extract each array of mac address and convert it to hexa with the
* following format 08-00-27-DC-4A-9E.
*/
for (int i = 0; i < mac.length; i++) {
macAddress.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
} else {
System.out.println("Address doesn't exist or is not accessible.");
}
} else {
System.out.println("Network Interface for the specified address is not found.");
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (SocketException e) {
e.printStackTrace();
}
return macAddress.toString();
}
public static void main(String[] args)
{
MacAddress address=new MacAddress();
System.out.println(address.getMacAddress());
}
}
Fo my system output is like this:
Output:
54-7D-2C-59-65-0F
Labels:
computermac,
MAC,
MACaddress,
pc mac,
systemmac
Subscribe to:
Posts (Atom)