?? 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 + -