fileaccess.java

来自「支持多线程的ftp下载源程序,没有用任何第三方组件」· Java 代码 · 共 33 行

JAVA
33
字号
package ext.down;

import java.io.*;

public class FileAccess implements Serializable
{
	RandomAccessFile oSaveFile = null;

	long nPos;

	public FileAccess(String sName, long npos) throws IOException
	{
		oSaveFile = new RandomAccessFile(sName, "rw");
		this.nPos = npos;
		oSaveFile.seek(nPos);
	}

	public synchronized int write(byte[] b, int nStart, int nLen)
	{
		try
		{
			int n = -1;
			oSaveFile.write(b, nStart, nLen);
			n = nLen;
			return n;
		}
		catch (IOException e)
		{
			return -2;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?