compare

Fast way to compare inputstreams

喜欢而已 提交于 2019-12-20 11:19:11
问题 I have a problem, I need to compare two inputstreams fast. Today I have a function like this: private boolean isEqual(InputStream i1, InputStream i2) throws IOException { try { // do the compare while (true) { int fr = i1.read(); int tr = i2.read(); if (fr != tr) return false; if (fr == -1) return true; } } finally { if (i1 != null) i1.close(); if (i2 != null) i2.close(); } } But it's really slow. I want to use buffered reads but have not come up with a good way of doing it. Some extra stuff

two string date compare with simple dateformat like EE,MMM dd yyyy

非 Y 不嫁゛ 提交于 2019-12-20 07:39:43
问题 i need to compare two string dates with SimpleDateformat like EE,MMM dd yyyy but when i compare it it will validate only the first value "EE" only other month,date and year not validating if anyone know this problem solution please help me to solve and thanks in advance to all 回答1: SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"/*or whatever your format is*/, Locale.US); try { Date actualDate = format.parse(actualDate); Date dateToCompare = format.parse(dateToCompare); if

Why can a user set a new password without the need to enter old password correct with my batch code?

蹲街弑〆低调 提交于 2019-12-20 07:14:58
问题 I wrote recently a folder locking program. My only problem is that when I need to change the password, e.g. I go to section newpass , the program doesn't seem to compare the old to the new password, but just uses any input given which defeats the purpose of having a password because everyone can just change it and than unlock the folder with it. Can someone double check my code and tell me why it is doing it. @echo off title Folder Locker by KBKOZLEV :SETPASS set/p password= <password.txt set

Compare 2 seperate csv files and write difference to a new csv file - Python 2.7

橙三吉。 提交于 2019-12-20 06:36:51
问题 I am trying to compare two csv files in python and save the difference to a third csv file in python 2.7. import csv f1 = open ("olddata/file1.csv") oldFile1 = csv.reader(f1) oldList1 = [] for row in oldFile1: oldList1.append(row) f2 = open ("newdata/file2.csv") oldFile2 = csv.reader(f2) oldList2 = [] for row in oldFile2: oldList2.append(row) f1.close() f2.close() set1 = tuple(oldList1) set2 = tuple(oldList2) print oldList2.difference(oldList1) I get the error message: Traceback (most recent

Comparing two RDDs

谁说我不能喝 提交于 2019-12-20 06:36:38
问题 I have two RDD[Array[String]], let's call them rdd1 and rdd2. I would create a new RDD containing just the entries of rdd2 not in rdd1 (based on a key). I use Spark on Scala via Intellij. I grouped rdd1 and rdd2 by a key (I will compare just the keys of the two rdds): val rdd1Grouped = rdd1.groupBy(line => line(0)) val rdd2Grouped = rdd2.groupBy(line => line(0)) Then, I used a leftOuterJoin : val output = rdd1Grouped.leftOuterJoin(rdd2Grouped).collect { case (k, (v, None)) => (k, v) } but

awk compare 2 files, 2 fields different order in the file, print or merge match and non match lines

五迷三道 提交于 2019-12-20 06:27:32
问题 I have two files, and I need to compare the second field from File1 and the first field from File2. If there is a match to print the second field of File2 and the entire line matched from File1 If there is no match to print "NOT FOUND" and the entire Line from File1 File1 \\FILESERV04\PCO;S:\CA\USII ECOM;/FS7_434D/FILESERV04/BUSII;;;;\\FILESERV04\PCO\;467,390,611 Bytes;11,225 ;157 \\FILESERV12\MINE$;S:\CA\Naka;/FS3_434D/FILESERV12/NAKA;;;;\\FILESERV12\MINE$\;0 Bytes;0 ;0 \\FILESERV12\INTEG$;S

how to edit my compare method

守給你的承諾、 提交于 2019-12-20 06:00:16
问题 I want to compare contens of my two txt files and write the different words in other file3.txt file I want to do compare method in this way to write another txt file. Also I dont have an error for coding I don't have a result. here is my code 回答1: I just ran your program with the following files and could not reproduce your problem. deneme1 abc def ghi deneme2 abc ghi klm And deneme3 was created with the following content: abc ghi EDIT It seems you want the opposite behaviour. Some of your

Compare similarity of two NSStrings

拜拜、爱过 提交于 2019-12-20 04:28:06
问题 I would like to compare two NSString s. If the user types "Stonehhengge", should get a "border on answer"="almost equals", because the right answer is: "Stonhenge". I would like a percentage of how much one string equals another. If "Stonhenge" is 9 letters, and the typed text contain 8 letters from "Stonhenge", but it's not equal to "Stonhenge", for example: "Stonehange" is not equal to "Stonhenge", but it's near - I'd like to know how near a match the strings are. I only know isEqual: . If

How would I make my custom generic type linked list in Java sorted?

纵然是瞬间 提交于 2019-12-20 04:11:06
问题 I am writing my own linked list in java that is of generic type instead of using the java collections linked list. The add method for the linked list is made up of the following code: public void add(T item, int position) { Node<T> addThis = new Node<T>(item); Node<T> prev = head; int i; if(position <= 0) { System.out.println("Error: Cannot add element before position 1."); } else if(position == 1) { addThis.setNext(head); head = addThis; } else { for(i = 1; i < position-1; i++) { prev = prev

How to Compare strings in java [duplicate]

旧城冷巷雨未停 提交于 2019-12-20 03:46:09
问题 This question already has answers here : How do I compare strings in Java? (23 answers) Closed 6 years ago . I have a program I'm making where when the user type in a mood, it will output a quote based on it. I need to tell the program if the user is happy, then output this text The problem is, I don't know how to get the program to recognize the input and output the text based on it... here's what I have for code so far. import java.util.Scanner; public class modd { public static void main