⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileaccess.java

📁 Java网络编程实例第2章实例.rar
💻 JAVA
字号:
package download;import java.io.*;/** * Title:        Java实现网络文件传输 * Description:  在客户端请求Web服务器传输指定文件,并将文件保存。 * Copyright:    Copyright (c) 2002 * Company: * @author 钟华 * @version 1.0 */public class FileAccess implements Serializable{    // 定义访问文件类  RandomAccessFile oSavedFile;  long nPos;  public FileAccess() throws IOException{    this("",0);  }  public FileAccess(String sName,long nPos) throws IOException{    oSavedFile = new RandomAccessFile(sName,"rw");    this.nPos = nPos;    oSavedFile.seek(nPos);  }  public synchronized int write(byte[] b,int nStart,int nLen){    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 + -