-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompareFiles.java
More file actions
84 lines (64 loc) · 2.05 KB
/
CompareFiles.java
File metadata and controls
84 lines (64 loc) · 2.05 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.application.areca.tests;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import com.myJava.file.FileSystemManager;
/**
* @author Olivier PETRUCCI
* <BR>
*
*/
/*
Copyright 2005-2015, Olivier PETRUCCI.
This file is part of Areca.
Areca is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Areca is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Areca; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
public class CompareFiles {
public static void main(String[] args) {
try {
if (args.length <= 2) {
System.out.println("Usage : [filename1] [filename2] [outfile]");
System.exit(-1);
}
File f1 = new File(args[0]);
File f2 = new File(args[1]);
File fout = new File(args[2]);
InputStream i1 = FileSystemManager.getFileInputStream(f1);
InputStream i2 = FileSystemManager.getFileInputStream(f2);
OutputStreamWriter writer = new OutputStreamWriter(FileSystemManager.getFileOutputStream(fout));
int b1 = -1, b2 = -1;
boolean eof1 = false;
boolean eof2 = false;
while (!eof1 || ! eof2) {
if (! eof1) {
b1 = i1.read();
if (b1 == -1) {
eof1 = true;
}
}
if (! eof2) {
b2 = i2.read();
if (b2 == -1) {
eof2 = true;
}
}
writer.write("\n" + (eof1 ? "EOF":""+b1) + " " + (eof2 ? "EOF":""+b2));
}
i1.close();
i2.close();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}