Click here to Skip to main content
       

Java

 
GeneralRe: Exception Pinmembercubocik29-Jan-13 1:49 
QuestionHibernate Pinmembersathish coder22-Jan-13 1:07 
AnswerRe: Hibernate PinmvpSandeep Mewara22-Jan-13 2:37 
AnswerRe: Hibernate PinmemberSultan Akyol22-Jan-13 9:25 
AnswerRe: Hibernate PinmemberGREG_DORIANcod25-Jan-13 11:48 
QuestionFor Java Project Pinmembersakurahito18-Jan-13 17:42 
AnswerRe: For Java Project PinmvpRichard MacCutchan18-Jan-13 23:00 
AnswerRe: For Java Project Pinmembercubocik22-Jan-13 2:08 
AnswerRe: For Java Project PinmvpSandeep Mewara22-Jan-13 2:39 
AnswerRe: For Java Project PinmemberSwarnendu0931-Jan-13 16:58 
Questionc Pinmemberravi bhukya17-Jan-13 23:38 
AnswerRe: c PinmvpRichard MacCutchan18-Jan-13 2:51 
AnswerRe: c Pinmember ProgramFOX18-Jan-13 23:58 
QuestionHow to convert byte array to hex string PinmemberIICTECH17-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 | :)
 
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 PinmvpRichard MacCutchan17-Jan-13 23:14 
GeneralRe: How to convert byte array to hex string PinmemberIICTECH18-Jan-13 2:02 
GeneralRe: How to convert byte array to hex string PinmvpRichard MacCutchan18-Jan-13 2:50 
QuestionImage Store in MySQL db Pinmemberayemyamya17-Jan-13 16:20 
AnswerRe: Image Store in MySQL db PinmvpRichard MacCutchan17-Jan-13 23:13 
AnswerRe: Image Store in MySQL db Pinmembersakurahito27-Jan-13 21:05 
QuestionHow to login server of router? [modified] Pinmemberngoanrazor17-Jan-13 15:11 
AnswerRe: How to auto login server of router? Pinmemberngoanrazor20-Jan-13 2:45 
GeneralRe: How to auto login server of router? Pinmembercubocik22-Jan-13 2:15 
GeneralRe: How to auto login server of router? Pinmemberngoanrazor22-Jan-13 14:01 
GeneralRe: How to auto login server of router? Pinmembercubocik29-Jan-13 1:46 
AnswerRe: How to login server of router? Pinmemberjschell22-Jan-13 8:15 
GeneralRe: How to login server of router? Pinmemberngoanrazor22-Jan-13 14:03 
GeneralRe: How to login server of router? Pinmemberjschell23-Jan-13 8:45 
GeneralRe: How to login server of router? Pinmemberngoanrazor23-Jan-13 14:56 
Questionam a beginner Pingrouponyebumichael15-Jan-13 9:42 
AnswerRe: am a beginner PinmvpRichard MacCutchan15-Jan-13 22:54 
GeneralRe: am a beginner Pinmembercubocik16-Jan-13 0:38 
GeneralRe: am a beginner PinmvpRichard MacCutchan16-Jan-13 0:52 
GeneralRe: am a beginner Pinmembercubocik16-Jan-13 0:55 
GeneralRe: am a beginner Pingrouponyebumichael16-Jan-13 11:03 
AnswerRe: am a beginner [modified] PinmemberApril Fans16-Jan-13 19:46 
GeneralRe: am a beginner PinmvpRichard MacCutchan16-Jan-13 23:40 
Questionhelp me please Pinmemberterzasek13-Jan-13 17:10 
AnswerRe: help me please PinmvpRichard MacCutchan13-Jan-13 22:23 
AnswerRe: help me please PinmemberAvidwan14-Jan-13 4:41 
GeneralRe: help me please PinmvpRichard MacCutchan14-Jan-13 6:22 
GeneralRe: help me please Pinmembercubocik16-Jan-13 0:40 
QuestionWebpage saver -- help Pinmembercubocik13-Jan-13 7:38 
SuggestionRe: Webpage saver -- help PinmvpRichard MacCutchan13-Jan-13 22:18 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 5:51 
GeneralRe: Webpage saver -- help PinmvpRichard MacCutchan14-Jan-13 6:12 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 6:34 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 6:39 
GeneralRe: Webpage saver -- help PinmvpRichard MacCutchan14-Jan-13 6:55 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 7:55 

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

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


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 30 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid