从给定文件中读取一个整数,并将其进行排序,然后再写入另一个文件中
编写一个程序,谢谢
编写一个程序,谢谢
解决方案 »
- jDialog关闭后如何实现父jFrame里面的jComboBox的刷新
- 求关于数字签名方面的资料
- 请问用JAVA怎么画直线和点,Graphics里面的的方法DrawLine是抽象的?
- 在排序的时候发现的一个奇怪的问题。。
- 如何用Java自定义snmp的mib信息库
- 关于接口作为方法返回值
- 请教:为何import javax.swing.*; 时提示错误:packsage javax.swing.* not found...
- Graphics下,使用drawString("天下"),无法正常显示????
- 真怪,为什么我的BufferReader.read会block在那边
- 关于String与StringBuffer问题的再次提问----在线等待
- 如何控制多窗体应用程序中各子窗体尺寸的改变?
- 拉着SUN找大家给个说法
import java.util.*;public class IntegerSort
{
public static void main(String[] args)
{
int[] arr = new int[10];
//这一段对你没有用,我写10个整数到文件中
try
{
OutputStream fos = new FileOutputStream("num.dat");
DataOutputStream dos = new DataOutputStream(fos);
int count=0;
for(int i=10;i>=1;i--)
dos.writeInt(i);
fos.close();
}
catch(Exception e)
{}
//读10个整数出来
try
{
InputStream fis = new FileInputStream("num.dat");
DataInputStream dis = new DataInputStream(fis);
for(int i=0;i<10;i++)
arr[i]=dis.readInt();
fis.close();
}
catch(Exception e)
{}
//下面排序,用系统的方法
Arrays.sort(arr);
//输出
for(int i=0;i<10;i++)
System.out.print(arr[i]+" ");
}
}
如果是的就需要下载poi这个包来操作excel文件
然后按文件的input,output流输入读写。