import java.io.*;
public class TestString {
public static void main(String[] args) throws Exception {
String str = "1";
String password = "x";
char s[] = str.toCharArray();
char p[] = password.toCharArray();
int n = s.length;
int m = p.length;
for (int k=0; k<n; ++k) {
int temp = s[k] + p[k%m];
s[k] = (char)temp;
}
System.out.println("1 : " + (int)s[0] + " " + s[0]); // 输出: 1 : 169 ?
str = new String(s);
File file = new File("Test.txt");
FileWriter fw = new FileWriter(file);
fw.write(str);
fw.flush();
fw.close();
FileReader fr = new FileReader(file);
String sss = "";
int b;
while ((b=fr.read()) != -1) {
System.out.println("2 : " + b + " " + (char)b); // 输出: 2 : 63 ?
sss = sss + (char)b;
}
System.out.println("str : " + str); // 输出: str : ?
System.out.println("sss : " + sss); // 输出: sss : ?
System.out.println(str.equals(sss)); // 输出: false
}
}