我想利用转换流把,键盘录入的任意五个数字,找到最大最小值,可是没成功,附上代码,跪求指点
package ioe;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.xml.sax.InputSource;
/*
* 接受键盘上的任意五个数字,存入数组并且找出最大数和最小数,在打印出来
* //把键盘上输入的数字变为字符数组
* */
public class Array {
public static void main(String[] args) {
man();
}
public static void man() {
BufferedReader br = null;
BufferedWriter bw = null;
char[] s = new char[6];
System.out.println("请输入任意五个数字");
try {
int mun = 0;
while (mun >= 5) {
// 接受读取,键盘上输入的内容,字符
br = new BufferedReader(new InputStreamReader(System.in));
// 输出流,输出到打印太上
bw = new BufferedWriter(new OutputStreamWriter(System.out));
// 把键盘上的转换为字符流,并且建立缓冲区
// int leng=null;//字符串
br.read(s);// 读取每行的字符创,存入s中
mun++;
}// 循环的括号
} catch (IOException e) {
}
int tem = 0;
int met = 0;
for (int i = 0; i < s.length; i++) {
if (s[i] < s[++i]) {
tem = s[i];
} else {
met = s[++i];
}
}
try {
bw.wait();
bw.wait();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
try {
if (br != null)
br.close();
} catch (IOException e) {
System.out.println("1");
}
try {
if (bw != null)
bw.close();
} catch (IOException e) {
System.out.println("2");
}
}
}
}
|