Below is my code, I'm not understanding the cause of the "ECHONEST api 4 NULL pointer exception":
下面是我的代码,我不理解“ECHONEST api 4 NULL指针异常”的原因:
package com.main;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.echonest.api.v4.EchoNestAPI;
import com.echonest.api.v4.EchoNestException;
import com.echonest.api.v4.Track;
import com.echonest.api.v4.TrackAnalysis;
public class SongAnalysis {
private static final String API_KEY = "14CPBOK0IFN0HRC0R";
public String getTempo(String fileName){
return null;
}
public static void main (String [] args)throws EchoNestException, IOException{
EchoNestAPI echoNest = new EchoNestAPI(API_KEY);
File file = new File("C:\\Users\\wooh\\workspace\\SongAnalysis\\songs\\b.mp3");
Track track = echoNest.uploadTrack(file,false );
track.waitForAnalysis(30000);
TrackAnalysis a = track.getAnalysis();
System.out.println("Tempo" + a.getTempo());
}
}
1 个解决方案
#1
0
The likely occurrences of your NPE are:
NPE可能出现的情况是:
-
echoNest
is null. -
track
is null. -
a
is null.
echoNest为null。
track为null。
a为空。
You would want to pinpoint the specific location that your NullPointerException
occurs, then ensure that when you instantiate the object, the object you need is being returned.
您可能想要确定发生NullPointerException的特定位置,然后确保在实例化对象时,返回所需的对象。
#1
0
The likely occurrences of your NPE are:
NPE可能出现的情况是:
-
echoNest
is null. -
track
is null. -
a
is null.
echoNest为null。
track为null。
a为空。
You would want to pinpoint the specific location that your NullPointerException
occurs, then ensure that when you instantiate the object, the object you need is being returned.
您可能想要确定发生NullPointerException的特定位置,然后确保在实例化对象时,返回所需的对象。