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

📄 tf.txt

📁 这个是学习网络编程的好好文档! 里面有一些老师发给的学习jsp的课件!
💻 TXT
字号:
1  import java.io.*;
2  public class TextFile
3  {
4    public static void type(String fileName)
5    {
6      int ch;
7      try
8      {
9        FileReader fr = new FileReader(fileName);
10        while((ch = fr.read())!=-1)
11          System.out.print((char)ch);
12        fr.close();
13      }
14      catch(IOException ex)
15      {
16        System.out.println("显示文件失败!");
17      }
18    }
19    public static void list(String fileName)
20    {
21      String aLine;
22      int lineNo = 1;
23      System.out.println("\n文件内容如下:");
24      try
25      {
26        FileReader fr = new FileReader(fileName);
27        BufferedReader br = new BufferedReader(fr);
28        while((aLine = br.readLine())!=null)
29        {
30          System.out.println(Integer.toString(lineNo)+"  "+aLine);
31          lineNo++;
32        }
33        fr.close();
34      }
35      catch(IOException ex)
36      {
37        System.out.println("列出文件失败!");
38      }
39    }
40    public static void copy(String source,String target)
41    {
42      int ch;
43      try
44      {
45        FileReader fr = new FileReader(source);
46        FileWriter fw = new FileWriter(target);
47        while((ch = fr.read())!=-1)
48          fw.write(ch);
49        fr.close();
50        fw.close();
51      }
52      catch(IOException ex)
53      {
54        System.out.println("复制文件失败!");
55      }
56    }
57    public static void format(String source,String target)
58    {
59      String aLine;
60      int lineNo = 1;
61      try
62      {
63        FileReader fr = new FileReader(source);
64        FileWriter fw = new FileWriter(target);
65        BufferedReader br = new BufferedReader(fr);
66        BufferedWriter bw = new BufferedWriter(fw);
67        while((aLine = br.readLine())!=null)
68        {
69          bw.write(Integer.toString(lineNo)+"  "+aLine+"\n\r");
70          lineNo++;
71        }
72        bw.flush();
73        fr.close();
74        fw.close();
75      }
76      catch(IOException ex)
77      {
78        System.out.println("格式化文件失败!");
79      }
80    }
81  }
82  
83  class tester
84  {
85    public static void main(String[] args)
86    {
87      //TextFile.type(args[0]);
88      //TextFile.list(args[0]);
89      TextFile.format(args[0],args[1]);
90      TextFile.type(args[1]);
91      
92    }
93  }

⌨️ 快捷键说明

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