JAVA NumberFormatExeption - PullRequest
       9

JAVA NumberFormatExeption

0 голосов
/ 21 октября 2019

У меня есть arrayList<long>, и мне нужно, чтобы значение, которое содержится, было с этим форматом 12334455l, поэтому число с l в конце для длинного типа, и я пробую 10000 раз и с 10000 типов или хака или метода длядобавив "l" к моим номерам, но у меня всегда есть NumberFormatExeption.

cheked: Long.parse valueOf String varible1 += String "l"; long variable2 = Long.parseLong(variable1)

, все эти методы работают, но когда я пытаюсь: List<Status> statuses = twitter.getRetweets(variable2);

у меня есть NumberFormatExeption

проблема в том, что тип getRetweets() длинный с "l" в конце.

package ApiSearch;
import java.util.ArrayList;
import java.util.List;

//import javax.net.ssl.SSLEngineResult.Status;

import twitter4j.Status;

//import org.apache.lucene.index.CheckIndex.Status;

import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;


public class GetRetweets {

     static long idT = 0;


    public static void main(String[] args) throws Exception {


        GetClassId tweetsGetId = new GetClassId("C:\\Users\\PATH\\COLECTION.txt");

        //number of lines in file
        System.out.println(tweetsGetId.countLines("C:\\Users\\PATH\\COLECTION.txt"));



        System.out.println(tweetsGetId.getTweetIdStr(0));
        System.out.println(tweetsGetId.getTweetId(738)+"    Last id in file");



        ArrayList<Long> aListOfId = new ArrayList<Long>();

        int j = 0;
        String l = "l";
        long el = Long.parseLong(l);

        int countOfLine = tweetsGetId.countLines("C:\\Users\\Tadix\\Desktop\\Col.txt");

        while(j <= countOfLine){
            try{

            String idStr = tweetsGetId.getTweetIdStr(j);
            idStr += "l";

            long idNotStr = Long.parseLong(idStr);
            //System.out.println(idStr);
            aListOfId.add(idNotStr);
            j++;
            }catch(Exception e){
                //continue;
                System.out.println("this is LastId of arrayList " + aListOfId.get(aListOfId.size()-1));
                if(j == countOfLine)
                    break;
            }


        }       

    int i = 0;


    for(int z = 0; z < aListOfId.get(aListOfId.size()-1); z++){

        long id = aListOfId.get(9);

        System.out.println(" Retourne jusqu'à 100 des premiers retweets d'un tweet donné ");

        try {

            Twitter twitter = new TwitterFactory().getInstance();
            System.out.println(" try ");
            List<Status> statuses = twitter.getRetweets(id);

            for (Status customer : statuses) {
                System.out.println("=========================== name : ============    "+customer.getUser());
            }

            for (Status status : statuses) {
                i++;
                System.out.println(i + " @ " + status.getUser().getScreenName() + " - " 
                + status.getText() +  " -la date du RT:" + status.getCreatedAt() +     
                "nombre de RT est:"   +  status.getRetweetCount() );
            }

            System.out.println("done.");
            System.exit(0);

        }
        catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get retweets: " + te.getMessage());
            System.exit(-1);
        }
    }
    }
}
...