使用Java OutputStream打印ASCII码

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * 向文件中打印ASCII表
 * @author zzw922cn
 *
 */
public class PrintASCII {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		//定义输出流
		OutputStream fileOutputStream = new FileOutputStream("1.txt");

		//ASCII从33到126之间的字符可以打印
		int start=33;
		int end=126;
		int total=94;

		int s=start;
		int real;
		int count=0;
		while(count<94) {
			for(int i=s;i<s+total;i++) {
				real=(i<=end)?i:(i%(end+1)+start);
				fileOutputStream.write(real);
			}
			fileOutputStream.write(13);
			fileOutputStream.write(10);
			s++;
			count++;
		}
		//关闭输出流
		fileOutputStream.close();
		System.out.println("Print successfully!");
	}

}

输出结果为:

!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~
"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!
#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"
$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#
%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$
&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%
‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&
()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘
)*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘(
*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()
+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*
,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+
-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,
./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-
/0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-.
0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./
123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0
23456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./01
3456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012
456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123
56789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./01234
6789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012345
789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456
89:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./01234567
9:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012345678
:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789
;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:
<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;
=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<
>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=
[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>?
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
GHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
JKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
KLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
LMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
NOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
OPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
QRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
STUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
TUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
UVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
VWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
WXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
YZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
Z[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]
\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][
]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]
_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^
`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_
abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`
bcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`a
cdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`ab
defghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abc
efghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcd
fghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcde
ghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdef
hijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefg
ijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefgh
jklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghi
klmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghij
lmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected]DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk
mnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijkl
nopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklm
opqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmn
pqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmno
qrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnop
rstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopq
stuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqr
tuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrs
uvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrst
vwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstu
wxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuv
xyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvw
yz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwx
z{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxy
{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz
|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{
}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|
~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}
时间: 2024-12-21 18:45:15

使用Java OutputStream打印ASCII码的相关文章

Java字符串跟ASCII码互转

1.由于项目中遇到,在服务器端起的jar包程序,给前台发消息后,前段收到的消息出现乱码情况,所以采取在后才发消息前先把消息字符串转成ASCII码再发往前台,前台采取在收到后台消息先把ASCII码转成字符串的解决方案进行解决. 1)将字符串转成ASCII的Java方法 public static String stringToAscii(String value) { StringBuffer sbu = new StringBuffer(); char[] chars = value.toCha

打印ASCII码

描述 输入一个除空格以外的可见字符(保证在函数scanf中可使用格式说明符%c读入),输出其ASCII码. 输入一个除空格以外的可见字符.输出一个十进制整数,即该字符的ASCII码.样例输入 A 样例输出 65源代码: #include <stdio.h> int main() { char a; scanf ("%c", &a); printf ("%d\n", a); return 0; }

1-2-07:打印ASCII码

总时间限制: 1000ms 内存限制: 65536kB 描述 输入一个除空格以外的可见字符(保证在函数scanf中可使用格式说明符%c读入),输出其ASCII码. 输入 一个除空格以外的可见字符. 输出 一个十进制整数,即该字符的ASCII码. 样例输入 A 样例输出 65 #include<stdio.h> int main() { char f; scanf("%c",&f); printf("%d\n",f); return 0; }

1.2打印ASCII码

描述 输入一个除空格以外的可见字符(保证在函数scanf中可使用格式说明符%c读入),输出其ASCII码. 输入一个除空格以外的可见字符.输出一个十进制整数,即该字符的ASCII码.样例输入 A 样例输出 65 #include<iostream> #include<cstring> #include<ctime> #include<cstdio> #include<queue> #include<cmath> #include<

java 字符与ASCII码互转

字符转对应ASCII码 // 方法一:将char强制转换为byte char ch = 'A'; byte byteAscii = (byte) ch; System.out.println(byteAscii); // 方法二:将char直接转化为int,其值就是字符的ascii int byteAscii1 = (int) ch; System.out.println(byteAscii1); ASCII码转字符 // 直接int强制转换为char int ascii = 65; char

如何由二进制ASCII码(010101)得到相应的字符

需求:有时在通信方面的一些工程,接收端接收到的往往是字符信息的ASCII码(0101)的东西,这串东西存到一个int型数组中(int a[7]),这个时候怎么解析相应的字符呢? 答案: #include <stdio.h> #include <math.h> int main() {           //0 1 2 3 4 5 6 int a[7]={0,0,0,0,1,1,0}; //"0"的ASCII码,注意倒序 int i; //循环变量 //打印AS

1008:ASCII码【JAVA算法】

题目描述 相信大家一定都知道大名鼎鼎的ASCII码,这次给你的任务是输入数字(表示ASCII码),输出相对应的字符信息. 输入格式 第一行为一个整数T(1<=T<=1000). 接下来包括T个正整数,由空白符分割.(空白符包括空格.换行.制表符) 这些整数不会小于32. 输出 在一行内输出相应的字符信息.(注意不要输出任何多余的字符) 样例输入 13 72 101 108 108 111 44 32 119 111 114 108 100 33 样例输出 Hello, world! impor

Java中二进制、十进制、十六进制及ASCII码与String及字节数组与十六进制之间的转换

public class DigitalTrans { /** * 数字字符串转ASCII码字符串 * * @param String * 字符串 * @return ASCII字符串 */ public static String StringToAsciiString(String content) { String result = ""; int max = content.length(); for (int i = 0; i < max; i++) { char c

2016.06.06 周一 C语言 将字符串根据字符的ASCII码从大到小排序并打印出字符串中的字符类型的总数

第一次变量冲突问题 解决了一个多小时,.... 代码如下: ↓ #include<stdio.h> #include<string.h> #define N 200 //输入字符串的最大长度 int main() { //************************输入开始部分******************************** printf("请输入字符串.(长度在200以内)\n\n"); int i=0,j,k,temp,lowLetter