可能重複:
Compare the content of 2 text files in java language文本字符串比較文件
我想比較兩個.txt文件串在Android應用程序。你能告訴我如何進行? 我想插入代碼這個
try {
URL url = new URL("httpurl");
URLConnection ucon = url.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ((current = bis.read()) != -1) {
baf.append((byte) current);
}
FileOutputStream fos = new FileOutputStream("/mnt/sdcard/random.txt");
fos.write(baf.toByteArray());
fos.close();
} catch (IOException e) {
Log.d("ImageManager", "Error: " + e);
}
如此簡單轉換成字符串兩個文件,並使用equals比較字符串... –
你想不比較兩個文件但找到兩個文件中相同的文本的一部分? – Arseniy
不,我希望兩個文件中都不相似的部分 – user1437027