private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String value = jTextField2.getText();
jTextField3.setText(value);
JOptionPane.showMessageDialog(null,"Hello, you are about to convert \n"
+ "this line of string values to hexadecimal\n"
+ ""
+ "this vlaue is " + value);
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String value = jTextField2.getText();
jTextField3.setText(value);
JOptionPane.showMessageDialog(null,"Hello, you are about to convert \n"
+ "this line of string values to hexadecimal\n"
+ ""
+ "this vlaue is " + value);
for(int i = 0; i < str.length(); i++)
{
char selection = str.charAt(i);
int asciiVal = (int)selection;
}
public static String dec2hex(int x)
{
int result = x;
int i = 0;
String hexBuffer = "";
while(result > 0) {
if(result % 16 > 9) {
switch((result % 16)) {
case 10:
hexBuffer += "A";
break;
case 11:
hexBuffer += "B";
break;
case 12:
hexBuffer += "C";
break;
case 13:
hexBuffer += "D";
break;
case 14:
hexBuffer += "E";
break;
case 15:
hexBuffer += "F";
break;
}
} else {
hexBuffer += (result % 16);
}
result /= 16;
i++;
}
hexBuffer = new StringBuilder(hexBuffer).reverse().toString();
return hexBuffer;
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.