课堂小作业:将奇数位的字母大写输出!
实验代码:
package file;
import java.io.*;
public class filetext {
public static void main(String[] args) throws Exception {
File f = new File("D:\\text");
InputStream out = new FileInputStream(f);
char a[] = new char[(int) f.length()];
for (int i = 0; i < a.length; i++) {
a[i] = (char) out.read();
if (i % 2 == 0) {
a[i] = (char) (a[i] - 32);
}
System.out.print(a[i]);
}
out.close();
}
}