randFile.write(resultBs, start, byteLen);
应该是read方法吧??
应该是read方法吧??
解决方案 »
- readUTF()的问题
- 怎么做一个java界面布局
- JAVA基础问题
- create可以用但select不能用的问题急急急
- 如何连接到ORACLE数据库???
- 菜鸟学java送分
- sessionbean调用entitybean的时候还需要像Client一样远程调用对象吗??
- 为什么在jbuilder3中编译的部分applet在浏览器中不能运行?
- List接口例程,String temp = (String)obj[i] ;向下转型疑问?
- 为什么再JAVA程序中输入 汉字会报错
- 使用Iterator来遍历Collection集合里的元素,到底能否改变元素的值?
- Httpclient 4.3 怎么模拟带JS的提交!
文件名后缀是rar
默认使用压缩软件打开
当然会出错
改了下,可以参考下
public static void main(String args[]) throws IOException {
String filePath = "D:\\aa.rar";
String dest="D:" + File.separator + "testfile.jar";
int flag=copyFileToDest(filePath,dest);
System.out.println("文件复制"+(flag==1?"成功":"失败")); }
public static int copyFileToDest(String src,String dest){
int flag=1;
File files = new File(src);
int start = 0;
int byteLen = (int) files.length();
byte[] resultBs = new byte[byteLen];
RandomAccessFile randFile = null;
try {
InputStream ins = new FileInputStream(files);
ins.read(resultBs, start, byteLen);
randFile = new RandomAccessFile(dest, "rw");
randFile.write(resultBs, start, byteLen);
ins.close();
randFile.close();
} catch (Exception e) {
flag=0;
e.printStackTrace();
}
return flag; }