Click here to Skip to main content
15,899,025 members
Home / Discussions / Java
   

Java

 
AnswerRe: For Java Project Pin
Richard MacCutchan18-Jan-13 23:00
mveRichard MacCutchan18-Jan-13 23:00 
AnswerRe: For Java Project Pin
cubocik22-Jan-13 2:08
cubocik22-Jan-13 2:08 
AnswerRe: For Java Project Pin
Sandeep Mewara22-Jan-13 2:39
mveSandeep Mewara22-Jan-13 2:39 
AnswerRe: For Java Project Pin
Swarnendu0931-Jan-13 16:58
Swarnendu0931-Jan-13 16:58 
Questionc Pin
ravi bhukya17-Jan-13 23:38
ravi bhukya17-Jan-13 23:38 
AnswerRe: c Pin
Richard MacCutchan18-Jan-13 2:51
mveRichard MacCutchan18-Jan-13 2:51 
AnswerRe: c Pin
Thomas Daniels18-Jan-13 23:58
mentorThomas Daniels18-Jan-13 23:58 
QuestionHow to convert byte array to hex string Pin
IICTECH17-Jan-13 17:57
IICTECH17-Jan-13 17:57 
Hi All,
I got a piece of code from google to convert byte array to hex string...i din't understand few lines of code can any on ehelp me to understand ?? Smile | :)

C#
public static String CellKeysGeneration() {

        byte[] btba = new byte[5];

        Random r = new Random();

        r.nextBytes(btba);

        for (int i = 0; i < btba.length; i++) {

            btba[i] = btba[i];

        }
        String str = tohexString(btba);
        return str;
    }

    public static String tohexString(byte[] bytes) {

        StringBuffer sb = new StringBuffer(bytes.length * 2);

        for (int i = 0; i < bytes.length; i++) {
            sb.append(tohex(bytes[i] >> 4));
            sb.append(tohex(bytes[i]));

        }

        return sb.toString();

    }

    public static char tohex(int nibble) {

        final char[] hexdigit = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
                '9', 'A', 'B', 'C', 'D', 'E' , 'F' };

        return hexdigit[nibble & 0xF];
    }


In above three functions,

1) I dint understand why in toHex function we are always performing "and" operartion with 0xF.

2) I dint understand why in tohexString function we are performing ">>" operation with 4.

Can any one help me to understand toHexString and toHex functions ?? Smile | :)

Thanks in advance !
AnswerRe: How to convert byte array to hex string Pin
Richard MacCutchan17-Jan-13 23:14
mveRichard MacCutchan17-Jan-13 23:14 
GeneralRe: How to convert byte array to hex string Pin
IICTECH18-Jan-13 2:02
IICTECH18-Jan-13 2:02 
GeneralRe: How to convert byte array to hex string Pin
Richard MacCutchan18-Jan-13 2:50
mveRichard MacCutchan18-Jan-13 2:50 
QuestionImage Store in MySQL db Pin
ayemyamya17-Jan-13 16:20
ayemyamya17-Jan-13 16:20 
AnswerRe: Image Store in MySQL db Pin
Richard MacCutchan17-Jan-13 23:13
mveRichard MacCutchan17-Jan-13 23:13 
AnswerRe: Image Store in MySQL db Pin
sakurahito27-Jan-13 21:05
sakurahito27-Jan-13 21:05 
QuestionHow to login server of router? Pin
ngoanrazor17-Jan-13 15:11
ngoanrazor17-Jan-13 15:11 
AnswerRe: How to auto login server of router? Pin
ngoanrazor20-Jan-13 2:45
ngoanrazor20-Jan-13 2:45 
GeneralRe: How to auto login server of router? Pin
cubocik22-Jan-13 2:15
cubocik22-Jan-13 2:15 
GeneralRe: How to auto login server of router? Pin
ngoanrazor22-Jan-13 14:01
ngoanrazor22-Jan-13 14:01 
GeneralRe: How to auto login server of router? Pin
cubocik29-Jan-13 1:46
cubocik29-Jan-13 1:46 
AnswerRe: How to login server of router? Pin
jschell22-Jan-13 8:15
jschell22-Jan-13 8:15 
GeneralRe: How to login server of router? Pin
ngoanrazor22-Jan-13 14:03
ngoanrazor22-Jan-13 14:03 
GeneralRe: How to login server of router? Pin
jschell23-Jan-13 8:45
jschell23-Jan-13 8:45 
GeneralRe: How to login server of router? Pin
ngoanrazor23-Jan-13 14:56
ngoanrazor23-Jan-13 14:56 
Questionam a beginner Pin
onyebumichael15-Jan-13 9:42
onyebumichael15-Jan-13 9:42 
AnswerRe: am a beginner Pin
Richard MacCutchan15-Jan-13 22:54
mveRichard MacCutchan15-Jan-13 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.