这是以ascii值打印我希望显示为字符串

时间:2017-09-19 02:10:53

标签: java

import java.io.FileInputStream;

import java.io.FileOutputStream;

class FileInput

{

    public static void main(String args[])
    {

        try{
            FileOutputStream fout= new FileOutputStream("a.txt");

            FileInputStream fin=new FileInputStream("a.txt");
            String str="1234";
            byte a[]=str.getBytes();
            fout.write(char(a));
            fout.close();
        int i=0;
        while((i=fin.read())!=-1)
    {
        System.out.println((i));// This is printing in ascii value i want to display as string 
    }
fin.close();


}
    catch(Exception e)
    {
        System.out.println(e);
    }
    }
}

1 个答案:

答案 0 :(得分:-1)

    try{
        FileOutputStream fout= new FileOutputStream("a.txt");

        FileInputStream fin=new FileInputStream("a.txt");
        String str="1234";
        byte a[]=str.getBytes();
        fout.write(a);
        fout.close();
    int i=0;
    while((i=fin.read())!=-1)
{
    System.out.println((char)i);
}

}