| |

VerySource

 Forgot password?
 Register
Search
Author: madwen

Ask: how to know the ASCII code of a character

[Copy link]

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-27 16:00:01
| Show all posts
private static String getASCIICode(String normalStr) {
StringBuffer buffer = new StringBuffer();
byte[] bitArray = normalStr.getBytes();
int length = bitArray .length;
for (int i = 0; i <length; i++)
{
buffer.append(Integer.toHexString(bitArray [i]));
}
return (new String(buffer));
}
//Only English strings

Give points! Give points! Ha ha
Reply

Use magic Report

0

Threads

11

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-7-27 20:45:02
| Show all posts
System.in.read() method returns an int
This int is the ASC code of the input character...
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-29 08:15:01
| Show all posts
Okay, thank you
Int is the most convenient
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list