Click here to Skip to main content
11,581,515 members (64,907 online)
   

Java

 
GeneralRe: Exception Pin
cubocik29-Jan-13 1:49
membercubocik29-Jan-13 1:49 
QuestionHibernate Pin
sathish coder22-Jan-13 1:07
membersathish coder22-Jan-13 1:07 
AnswerRe: Hibernate Pin
Sandeep Mewara22-Jan-13 2:37
mvpSandeep Mewara22-Jan-13 2:37 
AnswerRe: Hibernate Pin
Sultan Akyol22-Jan-13 9:25
memberSultan Akyol22-Jan-13 9:25 
AnswerRe: Hibernate Pin
GREG_DORIANcod25-Jan-13 11:48
memberGREG_DORIANcod25-Jan-13 11:48 
QuestionFor Java Project Pin
sakurahito18-Jan-13 17:42
membersakurahito18-Jan-13 17:42 
AnswerRe: For Java Project Pin
Richard MacCutchan18-Jan-13 23:00
mvpRichard MacCutchan18-Jan-13 23:00 
AnswerRe: For Java Project Pin
cubocik22-Jan-13 2:08
membercubocik22-Jan-13 2:08 
AnswerRe: For Java Project Pin
Sandeep Mewara22-Jan-13 2:39
mvpSandeep Mewara22-Jan-13 2:39 
AnswerRe: For Java Project Pin
Swarnendu0931-Jan-13 16:58
memberSwarnendu0931-Jan-13 16:58 
Questionc Pin
ravi bhukya17-Jan-13 23:38
memberravi bhukya17-Jan-13 23:38 
AnswerRe: c Pin
Richard MacCutchan18-Jan-13 2:51
mvpRichard MacCutchan18-Jan-13 2:51 
AnswerRe: c Pin
ProgramFOX18-Jan-13 23:58
member ProgramFOX18-Jan-13 23:58 
QuestionHow to convert byte array to hex string Pin
IICTECH17-Jan-13 17:57
memberIICTECH17-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 Pin
Richard MacCutchan17-Jan-13 23:14
mvpRichard MacCutchan17-Jan-13 23:14 
GeneralRe: How to convert byte array to hex string Pin
IICTECH18-Jan-13 2:02
memberIICTECH18-Jan-13 2:02 
GeneralRe: How to convert byte array to hex string Pin
Richard MacCutchan18-Jan-13 2:50
mvpRichard MacCutchan18-Jan-13 2:50 
QuestionImage Store in MySQL db Pin
ayemyamya17-Jan-13 16:20
memberayemyamya17-Jan-13 16:20 
AnswerRe: Image Store in MySQL db Pin
Richard MacCutchan17-Jan-13 23:13
mvpRichard MacCutchan17-Jan-13 23:13 
AnswerRe: Image Store in MySQL db Pin
sakurahito27-Jan-13 21:05
membersakurahito27-Jan-13 21:05 
QuestionHow to login server of router? Pin
ngoanrazor17-Jan-13 15:11
memberngoanrazor17-Jan-13 15:11 
AnswerRe: How to auto login server of router? Pin
ngoanrazor20-Jan-13 2:45
memberngoanrazor20-Jan-13 2:45 
GeneralRe: How to auto login server of router? Pin
cubocik22-Jan-13 2:15
membercubocik22-Jan-13 2:15 
GeneralRe: How to auto login server of router? Pin
ngoanrazor22-Jan-13 14:01
memberngoanrazor22-Jan-13 14:01 
GeneralRe: How to auto login server of router? Pin
cubocik29-Jan-13 1:46
membercubocik29-Jan-13 1:46 
AnswerRe: How to login server of router? Pin
jschell22-Jan-13 8:15
memberjschell22-Jan-13 8:15 
GeneralRe: How to login server of router? Pin
ngoanrazor22-Jan-13 14:03
memberngoanrazor22-Jan-13 14:03 
GeneralRe: How to login server of router? Pin
jschell23-Jan-13 8:45
memberjschell23-Jan-13 8:45 
GeneralRe: How to login server of router? Pin
ngoanrazor23-Jan-13 14:56
memberngoanrazor23-Jan-13 14:56 
Questionam a beginner Pin
onyebumichael15-Jan-13 9:42
grouponyebumichael15-Jan-13 9:42 
AnswerRe: am a beginner Pin
Richard MacCutchan15-Jan-13 22:54
mvpRichard MacCutchan15-Jan-13 22:54 
GeneralRe: am a beginner Pin
cubocik16-Jan-13 0:38
membercubocik16-Jan-13 0:38 
GeneralRe: am a beginner Pin
Richard MacCutchan16-Jan-13 0:52
mvpRichard MacCutchan16-Jan-13 0:52 
GeneralRe: am a beginner Pin
cubocik16-Jan-13 0:55
membercubocik16-Jan-13 0:55 
GeneralRe: am a beginner Pin
onyebumichael16-Jan-13 11:03
grouponyebumichael16-Jan-13 11:03 
AnswerRe: am a beginner Pin
April Fans16-Jan-13 19:46
memberApril Fans16-Jan-13 19:46 
GeneralRe: am a beginner Pin
Richard MacCutchan16-Jan-13 23:40
mvpRichard MacCutchan16-Jan-13 23:40 
Questionhelp me please Pin
terzasek13-Jan-13 17:10
memberterzasek13-Jan-13 17:10 
AnswerRe: help me please Pin
Richard MacCutchan13-Jan-13 22:23
mvpRichard MacCutchan13-Jan-13 22:23 
AnswerRe: help me please Pin
Avidwan14-Jan-13 4:41
memberAvidwan14-Jan-13 4:41 
GeneralRe: help me please Pin
Richard MacCutchan14-Jan-13 6:22
mvpRichard MacCutchan14-Jan-13 6:22 
GeneralRe: help me please Pin
cubocik16-Jan-13 0:40
membercubocik16-Jan-13 0:40 
QuestionWebpage saver -- help Pin
cubocik13-Jan-13 7:38
membercubocik13-Jan-13 7:38 
SuggestionRe: Webpage saver -- help Pin
Richard MacCutchan13-Jan-13 22:18
mvpRichard MacCutchan13-Jan-13 22:18 
GeneralRe: Webpage saver -- help Pin
cubocik14-Jan-13 5:51
membercubocik14-Jan-13 5:51 
GeneralRe: Webpage saver -- help Pin
Richard MacCutchan14-Jan-13 6:12
mvpRichard MacCutchan14-Jan-13 6:12 
GeneralRe: Webpage saver -- help Pin
cubocik14-Jan-13 6:34
membercubocik14-Jan-13 6:34 
GeneralRe: Webpage saver -- help Pin
cubocik14-Jan-13 6:39
membercubocik14-Jan-13 6:39 
GeneralRe: Webpage saver -- help Pin
Richard MacCutchan14-Jan-13 6:55
mvpRichard MacCutchan14-Jan-13 6:55 
GeneralRe: Webpage saver -- help Pin
cubocik14-Jan-13 7:55
membercubocik14-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
Web03 | 2.8.150603.1 | Last Updated 6 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid