src/org/jnetpcap/packet/format/FormatUtils.java
public static byte[] toByteArray(String source) {

		String s = source.replaceAll(" |\n", "");

		byte[] b = new byte[s.length() / 2];

		if ((s.length() % 2) != 0) {
			System.err.println(s);
			throw new IllegalArgumentException(
					"need even number of hex double digits [" + s.length() + "]");
		}

		for (int i = 0; i < s.length(); i += 2) {
			String q = s.substring(i, i + 2);
			// System.out.print(q);
			b[i / 2] = (byte) Integer.parseInt(q, 16);
		}

		return b;
	}
/**
	 * Parses a string containing hex numbers to a byte array.
	 * 
	 * @param source
	 *          source string
	 * @return byte array from the parsed data
	 */
Parses a string containing hex numbers to a byte array.

@param source
source string
@return byte array from the parsed data
Parses a string containing hex numbers to a byte array . @param source source string @return byte array from the parsed data
public static byte[] toByteArray(String source) {
		String s = source.replaceAll(" |\n", "");
		byte[] b = new byte[s.length() / 2];
		if ((s.length() % 2) != 0) {
			System.err.println(s);
			throw new IllegalArgumentException(
					"need even number of hex double digits [" + s.length() + "]");
		}
		for (int i = 0; i < s.length(); i += 2) {
			String q = s.substring(i, i + 2);
			b[i / 2] = (byte) Integer.parseInt(q, 16);
		}
		return b;
	}
public static byte [ ] toByteArray ( String source ) { String s = source . replaceAll ( " |\n" , "" ) ; byte [ ] b = new byte [ s . length ( ) / 2 ] ; if ( ( s . length ( ) % 2 ) != 0 ) { System . err . println ( s ) ; throw new IllegalArgumentException ( "need even number of hex double digits [" + s . length ( ) + "]" ) ; } for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { String q = s . substring ( i , i + 2 ) ; b [ i / 2 ] = ( byte ) Integer . parseInt ( q , 16 ) ; } return b ; }
Parses a string containing hex numbers to a byte array.
Parses a string containing hex numbers to a byte array .
// System.out.print(q);