java中几题,我是新手,25分全给,实在没多的,谢谢

2024-12-31 05:35:39
推荐回答(2个)
回答1:

回答第四:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyBytes {
public static void main(String[] args) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream("test1.txt");
out = new FileOutputStream("test2.txt");
int c;

while ((c = in.read()) != -1) {
out.write(c);
}

} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}

回答2:

int a=97;
int i=0;
for(i=a;i<123;i+=2){
System.out.print((char)i+" ");

}
i-=1;
for(int j=i;i>97;i-=2){
System.out.print((char)i+" ");
}