Posts

Showing posts from 2016

Compare Text in 2 files and write the difference in a new file

Here I am reading 2 files, first file data is added to list.second file data is added to another list.Then converting 2 list to 2 Hashset. Then i am removing 1st hashset from the 2nd one.In this process all the common string will get removed and the new Hashset will have the difference data.
/**
 * Getting 2 text files with single column data in each, need to find out the difference and write the difference between the 2 files to a new file.
 */
public class CompareTwoFiles {
public static List readcsv(String filename) {
List l=new ArrayList();
String tempstr = "";
String dataStr = "";
int rownum = 0;
try {
BufferedReader br = new BufferedReader(new FileReader(filename));
try {
String line = "";
while ((line = br.readLine()) != null) {
l.add(line);
//System.out.println(dataStr);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return l;
}

   public…

Capture AJAX response and assign to a variable using JQUERY

function checkforduplicateempname(){
 var message=true;
 /*Assigning AJAX response to a javascript variable*/
 var empId = $.ajax({
   url: 'checkforduplicateempname.relay',
   data: oMyForms,
   cache: false,
   contentType: false,
   processData: false,
   global: false,
   async:false,
   type: 'POST',
   success: function(data){
return data;
   },error:function(){
$("#empname").notify("Unable to check for duplicate title.","error");
   }
}).responseText; //end of ajax capturing the response
if(empId!='0'){
$("#empaname").notify("Duplicate Title.","error");
message=false;
}

return message;
}//end of function

How to retain the space of the td after hidding it in Jquery

Image
If you use the following code snippet to hide and show tds- the UI will get disturbed.
The next corresponding td will get shifted to the hidden td space.
var tablevar="#"+myTable;
 $(tablevar+' tr:eq('+i+')').find('td:eq(3)').show();
   $(tablevar+' tr:eq('+i+')').find('td:eq(2)').show();

So how to retain the td space and still achieve the functionality.
use the this code snippet.
var tablevar="#"+myTable;
$(tablevar+' tr:eq('+i+')').find('td:eq(3)').css("visibility", "hidden");
 $(tablevar+' tr:eq('+i+')').find('td:eq(2)').css("visibility", "hidden");

 $(tablevar+' tr:eq('+i+')').find('td:eq(4)').css("visibility", "visible");