バスの発車時刻を表示するアプリを作っているのですが
NullPointerExceptionのエラーが出て動きません
調べてみたのですが、結局どこでエラーが発生しているのかわからないので、対処法を教えていただきたいです.
java
1package com.ngsce.keisuke.nzdrivett; 2 3import android.support.v7.app.AppCompatActivity; 4import android.os.Bundle; 5import android.widget.TextView; 6 7import java.io.BufferedReader; 8import java.io.InputStream; 9import java.io.InputStreamReader; 10import java.text.DateFormat; 11import java.text.SimpleDateFormat; 12import java.util.Date; 13import java.util.Timer; 14import java.util.TimerTask; 15 16public class MainActivity extends AppCompatActivity { 17 int commonLineCount = 1; 18 int info = 1; 19 Timer timerMain; 20 int mainTime = 1; 21 int desS = 1; 22 String intTT = ""; 23 int intTTnum = 0; 24 String desTT = ""; 25 String disTTS = ""; 26 String disTTJ = ""; 27 Timer timerInfo; 28 int lineCountJ = 1; 29 String disInfo = ""; 30 String desJ = ""; 31 String disJ = ""; 32 Timer timerDes; 33 String disS = ""; 34 @Override 35 protected void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 38 timerMain.scheduleAtFixedRate( 39 new TimerTask() { 40 @Override 41 public void run() { 42 Date now = new Date(System.currentTimeMillis()); 43 DateFormat formatTime = new SimpleDateFormat("HHmm"); 44 String time = formatTime.format(now); 45 mainTime = Integer.parseInt(time); 46 try { 47 InputStream is = null; 48 BufferedReader br = null; 49 try { 50 is = getAssets().open("intTT.txt"); 51 br = new BufferedReader(new InputStreamReader(is)); 52 53 String str; 54 for (int i = 0; i < commonLineCount; i++) { 55 str = br.readLine(); 56 intTT = str; 57 } 58 } finally { 59 if (is != null) br.close(); 60 if (is != null) is.close(); 61 } 62 } catch (Exception e) { 63 e.printStackTrace(); 64 } 65 intTTnum = Integer.parseInt(intTT); 66 if (intTTnum < mainTime) { 67 commonLineCount++; 68 } 69 try { 70 InputStream is = null; 71 BufferedReader br = null; 72 try { 73 is = getAssets().open("desTT.txt"); 74 br = new BufferedReader(new InputStreamReader(is)); 75 76 String str; 77 for (int i = 0; i < commonLineCount; i++) { 78 str = br.readLine(); 79 desTT = str; 80 } 81 } finally { 82 if (is != null) br.close(); 83 if (is != null) is.close(); 84 } 85 } catch (Exception e) { 86 e.printStackTrace(); 87 } 88 if (desTT.startsWith("Y")) { 89 desS = 1; 90 } 91 if (desTT.startsWith("K")) { 92 desS = 3; 93 } 94 if (desTT.startsWith("G")) { 95 desS = 5; 96 } 97 if (desTT.startsWith("S")) { 98 desS = 7; 99 } 100 if (desTT.endsWith("I")) { 101 info = 0; 102 } 103 if (desTT.endsWith("N")) { 104 info = 1; 105 } 106 try { 107 InputStream is = null; 108 BufferedReader br = null; 109 try { 110 is = getAssets().open("disTT.txt"); 111 br = new BufferedReader(new InputStreamReader(is)); 112 113 String str; 114 for (int i = 0; i < commonLineCount; i++) { 115 str = br.readLine(); 116 disTTS = str; 117 } 118 } finally { 119 if (is != null) br.close(); 120 if (is != null) is.close(); 121 } 122 } catch (Exception e) { 123 e.printStackTrace(); 124 } 125 126 setContentView(R.layout.activity_main); 127 TextView SenpatsuTime = (TextView) findViewById(R.id.SenpatsuTime); 128 SenpatsuTime.setText(disTTS); 129 } 130 },10,30000); 131 132 } 133 134
(文字数が足りないので途中までです)
宜しくお願いします