private void getsearchvolume(
      TargetingIdeaServiceInterface targetserviceinterface,
      TargetingIdeaSelector trgtselector,
      String[] arr,
      RelatedToQuerySearchParameter searchparam) {
    try {
      searchparam.setQueries(arr);
      trgtselector.setSearchParameters(new SearchParameter[] {searchparam});

      TargetingIdeaPage page = targetserviceinterface.get(trgtselector);
      if (page.getEntries() != null
          && page.getEntries().length > 0) { // "\"" + keyword.getValue()+"\",

        for (TargetingIdea targetidea : page.getEntries()) {
          LinkedList<String> list = new LinkedList<String>();
          Map<AttributeType, MonthlySearchVolumeAttribute> map2 = Maps.toMap(targetidea.getData());
          MonthlySearchVolumeAttribute mnthlysrchvol =
              map2.get(AttributeType.TARGETED_MONTHLY_SEARCHES);
          MonthlySearchVolume[] att1 = mnthlysrchvol.getValue();
          for (MonthlySearchVolume trgtsrch : att1) {
            list.add(
                "\""
                    + arr[0]
                    + "\",\""
                    + trgtsrch.getCount()
                    + "\",\""
                    + trgtsrch.getMonth()
                    + "\",\""
                    + trgtsrch.getYear()
                    + "\"\n");
          }
          linkedhashmap2.put(arr[0], list);
        }
        System.out.println(
            "xxxxxxxxxxxxxxxxxxxxFINISHED WITH SEARCH VOLUMExxxxxxxxxxxxxxxxxxxxxxxx");
      }
    } catch (RemoteException remotex) {
      remotex.printStackTrace();
    }
  }
  public static void main(String[] args)
      throws RemoteException, ApiException, FileNotFoundException, IOException {
    String inputfile = args[0];
    String outputfile = args[1];

    TargetIdeas obj = new TargetIdeas();
    AdWordsServices adwordservices = new AdWordsServices();
    AdWordsSession session = null;
    String[] clientIDs = GoogleAdwordsAPI.customerIDs();
    for (String custID : clientIDs) {
      session = GoogleAdwordsAPI.adwordclient(custID);
    }

    TargetingIdeaServiceInterface targetserviceinterface =
        adwordservices.get(session, TargetingIdeaServiceInterface.class);

    TargetingIdeaSelector trgtselector = new TargetingIdeaSelector();
    trgtselector.setRequestType(RequestType.STATS);
    trgtselector.setIdeaType(IdeaType.KEYWORD);

    trgtselector.setRequestedAttributeTypes(
        new AttributeType[] {AttributeType.TARGETED_MONTHLY_SEARCHES});
    Paging paging = new Paging();
    paging.setStartIndex(0);
    paging.setNumberResults(1);
    trgtselector.setPaging(paging);

    RelatedToQuerySearchParameter searchparam = new RelatedToQuerySearchParameter();
    NetworkSearchParameter networksearchparam = new NetworkSearchParameter();

    NetworkSetting networksetting = new NetworkSetting();
    networksetting.setTargetGoogleSearch(true);
    networksetting.setTargetContentNetwork(false);
    networksetting.setTargetPartnerSearchNetwork(false);
    networksetting.setTargetSearchNetwork(true);

    networksearchparam.setNetworkSetting(networksetting);

    BufferedReader bufferdr =
        new BufferedReader(new InputStreamReader(new FileInputStream(inputfile)));
    List<String> list = new ArrayList<String>();
    String keyword;
    while ((keyword = bufferdr.readLine()) != null) {
      list.add(keyword);
    }
    bufferdr.close();
    System.out.println("~~~~~~~~~~~~loaded keywords in a list~~~~~~~~~~~~~~");

    String[] arr = new String[1];
    Iterator<String> itr = list.iterator();
    while (itr.hasNext()) {
      arr[0] = itr.next();
      obj.getsearchvolume(targetserviceinterface, trgtselector, arr, searchparam);
      arr = new String[1];
    }

    LinkedList<String> nullist = new LinkedList<String>();
    itr = list.iterator();
    while (itr.hasNext()) {
      String key = itr.next();
      if (!linkedhashmap2.containsKey(key)) {
        nullist.add("\"" + key + "\"," + null + "," + null + "," + null + "\n");
        linkedhashmap2.put(key, nullist);
      }
    }

    BufferedWriter bfrwriter =
        new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputfile)));
    bfrwriter.write("\"Keyword\",\"Search Volume\",\"Month\",\"Year\"\n");

    StringBuilder strbuildr = new StringBuilder();
    for (String key : linkedhashmap2.keySet()) {
      List<String> maplist = linkedhashmap2.get(key);
      System.out.println("size of list: " + maplist.size());
      itr = maplist.iterator();
      while (itr.hasNext()) {
        strbuildr = strbuildr.append(itr.next());
      }
      bfrwriter.write(strbuildr.toString());
      strbuildr = new StringBuilder();
      maplist.clear();
    }
    System.out.println("\n\nwritten data to o/p file...");
    bfrwriter.close();
    System.out.println("end.");
  }