自己用JAVA写的,第一个正式的“作品”。
1
//字符和数字之间的转换
2
import java.io.*;
3
4
class JavaBase
5

{
6
public static void main( String [] args ) throws IOException
7
{
8
showMenu();
9
String str = null;
10
do
11
{
12
byte [] bytes = new byte[10];
13
int ch = System.in.read( bytes );
14
str = new String( bytes, 0, ch-2 );
15
int choices = Integer.parseInt( str );
16
switch( choices )
17
{
18
case 1:
19
System.out.println( "The Char-Word Unicode:" );
20
System.out.println( "Please input the char you want to analyse:" );
21
System.out.println( "Ends With the Char 'q' " );
22
toNumer( System.in );
23
System.out.println( "Now Back the menu" );
24
showMenu();
25
break;
26
case 2:
27
System.out.println( "The Num To The Char Unicode:" );
28
System.out.println( "Please input the num you want to analyse:" );
29
System.out.println( "Ends With the Char 'q' " );
30
toChar( System.in );
31
showMenu();
32
break;
33
case 3:
34
System.out.println( "You choice to quit
" );;
35
return;
36
default:
37
System.out.println( "Please choise again :" );
38
showMenu();
39
}
40
}
41
while( str.compareTo( "quit" ) != 0 ) ;
42
}
43
44
static void showMenu()
45
{
46
System.out.println( "Please Input your Choice:" );
47
System.out.println( "1.Char To Num;2.Num To Char;3.Quit." );
48
}
49
50
// //字母转换数字
51
static void toNumer( InputStream is )
52
{
53
int x = 0;
54
do
55
{
56
try
57
{
58
x = is.read();
59
if( x !='\r' && x != '\n' )
60
System.out.println( x );
61
// if( x =='\r' )
62
// System.out.println( 13 );
63
// if( x == '\n' )
64
// System.out.println( 10 );
65
}
66
catch( Exception e )
67
{
68
//System.out.println( e.toString() );
69
}
70
}
71
while( x != 'q' );
72
}
73
74
//convert the num to char
75
static void toChar( InputStream is )
76
{
77
String str = null;
78
do
79
{
80
try
81
{
82
byte [] bytes = new byte[20];
83
int length = is.read( bytes );
84
// System.out.println( "The leagth : " + length );
85
str = new String( bytes,0,length-2 );
86
// System.out.println( "The String is : " + str );
87
// System.out.println( "The String length : " + str.length() );
88
int num = Integer.parseInt( str, 10 );
89
System.out.println( (char)num );
90
}
91
catch( Exception e )
92
{
93
// System.out.println( e.toString() );
94
}
95
}
96
while( str.compareTo( "q" )!= 0 );
97
}
98
}

2

3

4

5



6

7



8

9

10

11



12

13

14

15

16

17



18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34


35

36

37

38

39

40

41

42

43

44

45



46

47

48

49

50

51

52



53

54

55



56

57



58

59

60

61

62

63

64

65

66

67



68

69

70

71

72

73

74

75

76



77

78

79



80

81



82

83

84

85

86

87

88

89

90

91

92



93

94

95

96

97

98
