使用Java OutputStream列印ASCII碼

來源:互聯網
上載者:User

標籤:

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{|}~!"#$%&‘()*+,-./023456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./013456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012356789:;<=>[email protected]IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012346789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012345789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012345689:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./012345679:;<=>[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][\]^_`acdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abdefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcefghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdfghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdeghijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefhijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefgijklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghjklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghiklmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijlmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijkmnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklnopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmopqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnpqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnoqrstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnoprstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqstuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrtuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrsuvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstvwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuwxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvxyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwyz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxz{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxy{|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz|}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{}~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|~!"#$%&‘()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}



使用Java OutputStream列印ASCII碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.