📄 fileaccessi.java
字号:
package com.download;
import java.io.*;
/**
* 负责文件访问接口。
* @author yeqc
* 2008-06-28
*
*/
public class FileAccessI implements Serializable{
/**
* 随机访问文件对象引用
*/
RandomAccessFile oSavedFile;
/**
* 下载的断点
*/
long nPos;
public FileAccessI() throws IOException
{
this("",0);
}
/**
* 构造读取文件
* @param sName
* @param nPos
* @throws IOException
*/
public FileAccessI(String sName,long nPos) throws IOException
{
oSavedFile = new RandomAccessFile(sName,"rw");
this.nPos = nPos;
//设置文件指针的位置
oSavedFile.seek(nPos);
}
/**
* 文件下载数
* @param b
* @param nStart
* @param nLen
* @return
*/
public synchronized int write(byte[] b,int nStart,int nLen)
{
System.out.println("---write-------- ");
int n = -1;
try{
oSavedFile.write(b,nStart,nLen);
n = nLen;
}catch(IOException e)
{
e.printStackTrace ();
}
return n;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -