Posts

DFP with Google App Engine

See the code ************************************************************************************* package com.lin.web.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import java.util.logging.Logger; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.google.api.ads.common.lib.exception.ValidationException; import com.google.api.ads.dfp.appengine.oauth.CredentialException; import com.google.api.ads.dfp.jaxws.factory.DfpServices; import com.google.api.ads.dfp.jaxws.v201302.ApiException_Exception; import com.google.api.ads.dfp.jaxws.v201302.Network; import com.google.api.ads.dfp.jaxws.v201302.NetworkServiceInterface; import com.google.api.ads.dfp.lib.client.DfpSession; import com.lin.web.util.ClientLoginAuth; import com.lin.web.util.LinMobiileProperties; import com.lin.web.util.Lin...

Google Ads Developer Blog: Google App Engine for Java meet DFP API, Part 1: H...

Google Ads Developer Blog: Google App Engine for Java meet DFP API, Part 1: H... : We are excited to start discussing how to use the DFP API from within the Google App Engine (Java) environment. This first blog post in th...

Date using Java: create Data using year, month, day, hour, minute, seconds in Java

Creating  custom date using java 1) Using java.util.Date  int year=2013; int month=5;   // months starts from 0 to 11, as 0 stands January and 11 stands for December int day=15; int hour=12; int minute=58; int seconds=47; *** Date utilDateObj=new Date(year,month,day,hour,minute,seconds); ***  This is depricated. We recommend to use Calander as given below: Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, seconds); Date lastUpdatedDate = calendar.getTime();

Impetus Interview questions: Code-2

What will be the output of the following... class A{ public static void main(String [] arg){         String s1="hello";         String s2=new String("hello");         System.out.println(s1==s2);         String s3=new String("world");         String s4=new String("world");                 System.out.println(s3==s4);         System.out.println(s1.equals(s2));         System.out.println(s3.equals(s4));         String s5="hello";         System.out.println(s1==s5);     } } Output:  See here..... false false true true true s1 == s2 : false, both refernece variable pointing to different objects s3 == s4 : false, both refernece variable poin...

Impetus Interview Questions: Code Snipet 1

What will be the output of the code? interface TestOne{     int limit=100;     void display();    } interface TestTwo{     int limit=200;     void display();    } public class TestInterface implements TestOne,TestTwo{     //int limit=0;     @Override     public void display() {         System.out.println("Hello... Test interface...."+limit);             }         public static void main(String [] arg){         TestInterface obj=new TestInterface();         obj.display();      } } ------------------------------------------- Output: Compiler error at System.out.println(....) : The field "limit" is ambiguous.

Read file from google cloud storage using Java

You can read file from google cloud storage using following code.... public void readTextFileOnly(String fileName) {          log.info("Reading from google cloud storage,fileName:"+fileName);         FileService fileService = FileServiceFactory.getFileService();         String filename = "/gs/" + BUCKET_NAME + "/" + fileName;         log.info("Reading from google cloud storag: filename:"+filename);         AppEngineFile readableFile = new AppEngineFile(filename);         FileReadChannel readChannel;         try {                 readChannel = fileService.openReadChannel(readableFile, false);                 BufferedReader reader = new BufferedReader(Chann...

Blowfish decryption: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher

Problem : Blowfish decryption+  javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher Solution: Always check your data whether it is a multiple of 8 bit or not.               if(decodedBytes.length % 8 != 0){ //not a multiple of 8                    System.out.println("decodedBytes is not padded properly in 8 bits");                    //create a new array with a size which is a multiple of 8                    byte[] padded = new byte[decodedBytes.length + 8 - (decodedBytes.length % 8)];                    //copy the old array into it     ...