そのため、いくつかのコードを検討しましたが、このヌル ポインター例外エラーのトラブルシューティングを行うことはできません。
ソースコード行 2290 から 3153 までのテーブルを解析しようとしていますhttp://pastebin.com/DjGHED5t
ただし、CSS クエリの 1 つでコードが失敗し、その理由がわかりません。
public void updateCompanyIs()throws IOException{
investoolsLogin();
Document doc = Jsoup.connect("http://toolbox.investools.com/graphs/fundamentalAnalysis.iedu?report=BS&symbol="+(Ticker)).get();
// Elements table = doc.select("table");
/**LINE 72**/
Elements columns = doc.getElementById("fundamentalsForm").children().select("table").get(0).select("tr").get(0).select("td");
Iterator<Element> columnIterator = columns.iterator();
int col = 0;
int row = 0;
while (columnIterator.hasNext()) {
Element column = columnIterator.next();
Elements rows = column.select("table").get(0).select("tr");
Iterator<Element> rowsIterator = rows.iterator();
col = col + 1;
while (rowsIterator.hasNext()){
row = row + 1;
//Element rowIterator.next = ;
incomeStatementInfo[col][row] = rowsIterator.next();
}
}
}
public void updateCompanyBs()throws IOException{
investoolsLogin();
Document doc = Jsoup.connect("http://toolbox.investools.com/graphs/fundamentalAnalysis.iedu?report=BS&symbol="+(Ticker)).get();
// Elements table = doc.select("table");
Elements columns = doc.getElementById("fundamentalsForm").children().select("table").get(0).select("tr").get(0).select("td");
Iterator<Element> columnIterator = columns.iterator();
int col = 0;
int row = 0;
while (columnIterator.hasNext()) {
Element column = columnIterator.next();
Elements rows = column.select("table").get(0).select("tr");
Iterator<Element> rowsIterator = rows.iterator();
col = col + 1;
while (rowsIterator.hasNext()){
row = row + 1;
//Element rowIterator.next = ;
balanceSheetInfo[col][row] = rowsIterator.next();
}
}
}
public void updateCompanyCf()throws IOException{
investoolsLogin();
Document doc = Jsoup.connect("http://toolbox.investools.com/graphs/fundamentalAnalysis.iedu?report=BS&symbol="+(Ticker)).get();
// Elements table = doc.select("table");
Elements columns = doc.getElementById("fundamentalsForm").children().select("table").get(0).select("tr").get(0).select("td");
Iterator<Element> columnIterator = columns.iterator();
int col = 0;
int row = 0;
while (columnIterator.hasNext()) {
Element column = columnIterator.next();
Elements rows = column.select("table").get(0).select("tr");
Iterator<Element> rowsIterator = rows.iterator();
col = col + 1;
while (rowsIterator.hasNext()){
row = row + 1;
//Element rowIterator.next = ;
cashFlowsInfo[col][row] = rowsIterator.next();
}
}
}
public void updateCompanyInfo(String Ticker) throws IOException {
/** LINE 134**/
updateCompanyIs();
updateCompanyBs();
updateCompanyCf();
}
}
これはエラーです:
Exception in thread "main" java.lang.NullPointerException
at Company.updateCompanyIs(Company.java:72)
at Company.updateCompanyInfo(Company.java:134)
at Company.<init>(Company.java:41)
at AppGUI.main(AppGUI.java:124)
そして、これは私の AppGUI です:
public static void main(String[] args) throws Exception{
Company company = new Company("KO"); // Creates new Company. Updating methods are called from constructor automatically.
AppGUI frame = new AppGUI(company); // Creates new App GUI. Various panes are initialized from constructor.
frame.retrieveGUI(company);
frame.setTitle("Financial Calculator | Ratios");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(1000, 500));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
私の JSOUP コードは正しいと思いますが、select 要素と node 要素、およびクエリで混乱する可能性があります。誰かが助けることができれば、それは大歓迎です。