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

📄 sh6.java

📁 1.创建文件和目录,并显示系统目录下sysio.ini文件的创建时间。 2.创建一个顺序文件
💻 JAVA
字号:
import java.io.*;
import java.util.*;
class Create{
    File file1,file2;
    Create(){
        File dir=new File("D:\1000");
        dir.mkdir();
        file1=new File(dir,"sh.txt");
        file2=new File("C:\test","sysio.ini");
    }
    long showtime(){
        return file2.lastModified();
    }
}
class FileFound{
    Scanner reader=new Scanner(System.in);
    /*String [] input(){
        for (int i = 0; i < s.length; i++) {
            while (reader.hasNextLine()) {
                s[i] = reader.nextLine();
            }
        }
        return s;
    }*/
    void bytefile(){
	File file=new File("test1.txt");
        byte b[];
        while(reader.hasNextByte){
		b[]=reader.nextByte;
	}
        try{
            FileOutputStream out=new FileOutputStream(file);
            out.write(b);
            out.close();
            FileInputStream in=new FileInputStream(file);
            while(in.read(b)!=-1){
                System.out.println(in.read(b));
            }
        }
        catch(IOException e){
            System.out.println(e);
        }
    }
 /*   void charfile(){
	String s;
        while(reader.hasNextLine){
		s[]=reader.nextLine;
		char c=s.toCharArray();
	}
        try{
            FileWriter out=new FileWriter(file);
            out.write(c);
            out.close();
            FileReader in=new FileReader(file);
            while(in.read(c)!=-1){
		String str=new String(c);
                System.out.println(str);
            }
            in.close();
        }
        catch(IOException e){
            System.out.println(e);
        }
    }*/
    bufferfile(){

}
}
public class Sh6 {
    public static void main(String args[]) {
        Create a=new Create();
        System.out.println(a.showtime());
        System.out.println(a.file1.getName());
        System.out.println(a.file2.getName());
        FileFound ex=new FileFound();
        ex.bytefile();
        //ex.charfile();
    }
}

⌨️ 快捷键说明

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