-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuicksort.java
More file actions
57 lines (48 loc) · 1.48 KB
/
Quicksort.java
File metadata and controls
57 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;
// -------------------------------------------------------------------------
/**
* Write a one-sentence summary of your class here. Follow it with additional
* details about its purpose, what abstraction it represents, and how to use it.
*
* @author wenfeng ren
* @version Nov 1, 2014
*/
public class Quicksort
{
// ----------------------------------------------------------
/**
* main method.
*
* @param args inputs
* @throws IOException
*/
public static void main(String[] args)
throws IOException
{
String disk = args[0];
int numBuffer = Integer.parseInt(args[1]);
String statFile = args[2];
// stat info update
Stat.fileName = disk;
long start = System.currentTimeMillis();
// sort file
Sorting sorting = new Sorting(disk, numBuffer);
sorting.sort();
// flush when sorting is done.
sorting.flush();
long end = System.currentTimeMillis();
// update stat info.
Stat.executionTime = end - start;
// write stat info to file:
File stat = new File(statFile);
stat.createNewFile();
FileWriter statfileWriter = new FileWriter(stat, true);
BufferedWriter statOut = new BufferedWriter(statfileWriter);
statOut.write(Stat.output());
statOut.flush();
statOut.close();
}
}