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

📄 randomread.java

📁 这个都是一些Java的IO相关的一些源码
💻 JAVA
字号:
//randomRead.Java
import java.io.*;
public class randomRead
{
	public static void main(String args[]) throws IOException{
	System.out.println("Please enter a directory that the file located in:"); 
                StringBuffer stfDir = new StringBuffer();
                char ch;
                while(( ch=(char) System.in.read())!='\n')
                {
                        stfDir.append(ch);
                } 
                File dir = new File(stfDir.toString());
                System.out.println("Please enter a filename that want to read:"); 
                StringBuffer stfFilename = new StringBuffer();
                char c;
                while((c = (char)System.in.read())!='\n')
                {
                        stfFilename.append(ch);
                } 
                File readFrom = new File(dir,stfFilename.toString());
                if(readFrom.isFile() && readFrom.canWrite() && readFrom.canRead())
                { 
                        RandomAccessFile rafFile =new RandomAccessFile(readFrom,"rw"); 
                        while(rafFile.getFilePointer()<rafFile.length())
                                System.out.println(rafFile.readLine());
                        rafFile.close();
                }
                else
                        System.out.println("File cann't be read!");
        }
}

⌨️ 快捷键说明

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