The main application of IO's randomaccessfile (I heard that the breakpoint is also implemented)
Import java.io. *;
Class fen {
String filename;
Int size;
Fen (string filename, string size) {
THIS.FILENAME = filename;
THIS.SIZE = Integer.Parseint (size) * 1024;
}
Public void cut () throws exception {
INT maxx = 0;
File infile = new file (filename);
INT fileLength = (int) infile.length (); // Get the size of the file
INT value; // Number of points to be divided
RandomaccessFile Inn = New RandomaccessFile (Infile, "R"); // Open the file to be split
Value = fileLength / size;
INT i = 0;
INT j = 0;
/ / Output files according to the number of points to be divided
For (; j File outfile = new file (Infile.getName () J "ZZII"); RandomaccessFile Outt = New RandomaccessFile (Outfile, "RW"); Maxx = size; For (; i Outt.write (Inn.Read ()); } Outt.close (); } File outfile = new file (Infile.getName () J "ZZII"); RandomaccessFile Outt = New RandomaccessFile (Outfile, "RW"); For (; i Outt.write (Inn.Read ()); } Outt.close (); Inn.Close (); } } Class HE { String filename; String filtername; HE (String FileName, String Filtername) { THIS.FILENAME = filename; This.Filtername = filtername; } Public void unite () throws exception { String [] TT; File infile = new file ("."); // file in the current directory File outfile = new file (filename); // get the output name RandomaccessFile Outt = New RandomaccessFile (Outfile, "RW"); / / A file name that meets the requirements Tt = infile.list (new filenamefilter () { Public Boolean Accept (File Dir, String Name) { String rr = new file (name) .tostring (); Return rr.endswith (filtername); } }); // Print the name of the file For (INT i = 0; i System.out.println (TT [i]); } // Open all files to write to a file for (int i = 0; i Infile = new file (tt [i]); RandomaccessFile Inn = New RandomaccessFile (Infile, "R"); INT C; While ((c = in.read ())! = - 1) Outt.write (c); } Outt.close (); } } Public class test { Public static void main (final string [] args "throws exception { IF (args.length == 0) { PRINT (); Return; } IF (Args [0]. Equals ("- c")) { Fen cutt = new fen (args [1], args [2]); Cutt.cut (); } Else IF (Args [0]. Equals ("- r")) { He He He = New He (Args [1], Args [2]); Hee.Unite (); } Else PRINT (); } Public static void print () { System.out.println ("USAGE: / N: Java Test -c File1 Size") "); } }