ユーザーが入力するすべての文字を印刷したいのですが、私のプログラムはユーザーが入力する最後の値のみを印刷し、最後の値のみが に記録されAscii.txt
ます。このように見えるはずです
例: ユーザー入力 A、B、c、C
コンマも削除したいのですが、できません:(
「Ascii.txt」の出力は次のようになります。
A = 65
B = 66
c = 99
C = 67
私はまだ学生でプログラミングは初めてなので、私を笑わないでください。どうもありがとう
import java.io.*;
public class NewClass2{
public static void main(String args[]) throws IOException{
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please Enter letters separated by comma: ");
String str = buff.readLine();
for ( int i = 0; i < str.length(); ++i )
{
char c = str.charAt(i);
int j = (int) c;
System.out.println(c +" = " + j);
{
try
{
FileWriter fstream = new FileWriter("Ascii.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write(c+" = "+j);
out.close();
}catch (Exception e){
}
}
}
}
}