Posts

convert file to string

public static String readFile(String filePath){ BufferedReader br = null; FileReader fr = null; StringBuilder sb = new StringBuilder(); try { fr = new FileReader(filePath); br = new BufferedReader(fr); String sCurrentLine; br = new BufferedReader(new FileReader(filePath)); while ((sCurrentLine = br.readLine()) != null) { sb.append(sCurrentLine); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null) br.close(); if (fr != null) fr.close(); } catch (IOException ex) { ex.printStackTrace(); } } return sb.toString(); }

Java Generics PECS – Producer Extends Consumer Super

Java Generics PECS – Producer Extends Consumer Super

XL Sheet Formulas

XL sheet formula's: 1. SUM :- Formula: =SUM(5, 5) or =SUM(A1, B1) or =SUM(A1:B5) 2. COUNT :- The count formula counts the number of cells in a range that have numbers in them. Formula: =COUNT(A1:A10) 3. COUNTA :- Counts the number of non-empty cells in a range. It will count cells that have numbers and/or any other characters in them. Formula: =COUNTA(A1:A10) 4. LEN :- The LEN formula counts the number of characters in a cell. Be careful though! This includes spaces. Formula: =LEN(A1) 5. TRIM :- Gets rid of any space in a cell, except for single spaces between words. Formula: =TRIM(A1) 6. RIGHT, LEFT, MID Formulas: = RIGHT(text, number of characters), =LEFT(text, number of characters), =MID(text, start number, number of characters). RIGHT(A1,2) 7. CONCATENATE :- A fancy word for combining data in 2 (or more) different cells into one cell. Formula: =CONCATENATE(A1," ", B2)

Copy And Delete files with Batch Code

Copy:- xcopy /y C:\Folder1 C:\Folder2 Comment:- ::xcopy /y C:\Folder1 C:\Folder2 Delete files in Folder:- set folder="C:\Folder1" cd /d %folder% for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q) Change directory: C to D:  D: cd D:\Project\myProj start/up app Ref: http://www.makeuseof.com/tag/use-windows-batch-file-commands-automate-repetitive-tasks/

java Interview Questions

Break And Continue: Break: skips the iteation continue: skips current iteration only program:- System.out.println("Break :");     for(int i=0;i<8;i++){     if(i==5){     break;     }     System.out.println(i);     }     System.out.println("bye bye..");     System.out.println("*****");     System.out.println("Continue :");     for(int i=0;i<8;i++){     if(i==5){     continue;     }     System.out.println(i);     }     System.out.println("bye bye.."); out put: Break: 0 1 2 3 4 bye bye.. ***** continue 0 1 2 3 4 6 7 bye bye..