質問編集履歴

5

削除された内容の復元を行いました

2020/12/22 02:24

投稿

w30P9ZaR25lAQGo
w30P9ZaR25lAQGo

スコア1

test CHANGED
@@ -1 +1 @@
1
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1
+ Integer.parseIntが数値なのに変換できない
test CHANGED
@@ -1 +1,91 @@
1
+ package controller;
2
+
3
+ import java.io.BufferedReader;
4
+
5
+ import java.io.FileInputStream;
6
+
7
+ import java.io.IOException;
8
+
9
+ import java.io.InputStreamReader;
10
+
11
+ import java.util.ArrayList;
12
+
13
+ import java.util.List;
14
+
15
+ import lombok.extern.slf4j.Slf4j;
16
+
17
+ import model.TestPointModel;
18
+
19
+ @Slf4j
20
+
21
+ public class Execute {
22
+
23
+ public static void main(String[] args) {
24
+
25
+ String line;
26
+
27
+ List<TestPointModel> list = new ArrayList<TestPointModel>();
28
+
29
+ try {
30
+
31
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\TEMP\お試しデータ.csv"))); //1レコード5カラムで、カラム名なしのtsvデータ(90,80,70,60,50など)
32
+
33
+ while ((line = br.readLine()) != null) {
34
+
35
+ var csvDate = line.split(",");
36
+
37
+ log.debug("csv datta is" + csvDate);
38
+
39
+ TestPointModel tpm = new TestPointModel();
40
+
41
+ System.out.print(csvDate[0].getClass());
42
+
1
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
43
+ ** tpm.setNationalLanguage(Integer.parseInt(csvDate[0]));
44
+
45
+ tpm.setMath(Integer.parseInt(csvDate[1]));
46
+
47
+ tpm.setSociety(Integer.parseInt(csvDate[2]));
48
+
49
+ tpm.setScience(Integer.parseInt(csvDate[3]));
50
+
51
+ tpm.setEnglish(Integer.parseInt(csvDate[4]));**
52
+
53
+ list.add(tpm);
54
+
55
+ }
56
+
57
+ list.forEach(e -> System.out.println());
58
+
59
+ } catch (IOException e) {
60
+
61
+ // TODO 自動生成された catch ブロック
62
+
63
+ e.printStackTrace();
64
+
65
+ }
66
+
67
+ }
68
+
69
+ }
70
+
71
+ ------------------------------------------------------------------------
72
+
73
+ package model;
74
+
75
+ import lombok.Data;
76
+
77
+ @Data
78
+
79
+ public class TestPointModel {
80
+
81
+ private int nationalLanguage;
82
+
83
+ private int math;
84
+
85
+ private int science;
86
+
87
+ private int society;
88
+
89
+ private int english;
90
+
91
+ }

4

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

2020/12/22 02:24

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Integer.parseIntが数値なのに変換できない
1
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
test CHANGED
File without changes

3

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

2020/12/05 16:38

投稿

w30P9ZaR25lAQGo
w30P9ZaR25lAQGo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -1,117 +1 @@
1
- package controller;
2
-
3
-
4
-
5
- import java.io.BufferedReader;
6
-
7
- import java.io.FileInputStream;
8
-
9
- import java.io.IOException;
10
-
11
- import java.io.InputStreamReader;
12
-
13
- import java.util.ArrayList;
14
-
15
- import java.util.List;
16
-
17
-
18
-
19
- import lombok.extern.slf4j.Slf4j;
20
-
21
- import model.TestPointModel;
22
-
23
-
24
-
25
- @Slf4j
26
-
27
- public class Execute {
28
-
29
-
30
-
31
- public static void main(String[] args) {
32
-
33
- String line;
34
-
35
- List<TestPointModel> list = new ArrayList<TestPointModel>();
36
-
37
- try {
38
-
39
- BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\TEMP\お試しデータ.csv"))); //1レコード5カラムで、カラム名なしのtsvデータ(90,80,70,60,50など)
40
-
41
-
42
-
43
- while ((line = br.readLine()) != null) {
44
-
45
- var csvDate = line.split(",");
46
-
47
- log.debug("csv datta is" + csvDate);
48
-
49
- TestPointModel tpm = new TestPointModel();
50
-
51
- System.out.print(csvDate[0].getClass());
52
-
53
-
54
-
55
- ** tpm.setNationalLanguage(Integer.parseInt(csvDate[0]));
1
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
56
-
57
- tpm.setMath(Integer.parseInt(csvDate[1]));
58
-
59
- tpm.setSociety(Integer.parseInt(csvDate[2]));
60
-
61
- tpm.setScience(Integer.parseInt(csvDate[3]));
62
-
63
- tpm.setEnglish(Integer.parseInt(csvDate[4]));**
64
-
65
- list.add(tpm);
66
-
67
- }
68
-
69
- list.forEach(e -> System.out.println());
70
-
71
-
72
-
73
- } catch (IOException e) {
74
-
75
- // TODO 自動生成された catch ブロック
76
-
77
- e.printStackTrace();
78
-
79
- }
80
-
81
-
82
-
83
-
84
-
85
- }
86
-
87
-
88
-
89
- }
90
-
91
- ------------------------------------------------------------------------
92
-
93
- package model;
94
-
95
-
96
-
97
- import lombok.Data;
98
-
99
-
100
-
101
- @Data
102
-
103
- public class TestPointModel {
104
-
105
- private int nationalLanguage;
106
-
107
- private int math;
108
-
109
- private int science;
110
-
111
- private int society;
112
-
113
- private int english;
114
-
115
-
116
-
117
- }

2

csvデータの内容記述

2020/12/05 16:37

投稿

w30P9ZaR25lAQGo
w30P9ZaR25lAQGo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -36,7 +36,9 @@
36
36
 
37
37
  try {
38
38
 
39
- BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\TEMP\お試しデータ.csv")));
39
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\TEMP\お試しデータ.csv"))); //1レコード5カラムで、カラム名なしのtsvデータ(90,80,70,60,50など)
40
+
41
+
40
42
 
41
43
  while ((line = br.readLine()) != null) {
42
44
 
@@ -50,7 +52,7 @@
50
52
 
51
53
 
52
54
 
53
- tpm.setNationalLanguage(Integer.parseInt(csvDate[0]));
55
+ ** tpm.setNationalLanguage(Integer.parseInt(csvDate[0]));
54
56
 
55
57
  tpm.setMath(Integer.parseInt(csvDate[1]));
56
58
 
@@ -58,7 +60,7 @@
58
60
 
59
61
  tpm.setScience(Integer.parseInt(csvDate[3]));
60
62
 
61
- tpm.setEnglish(Integer.parseInt(csvDate[4]));
63
+ tpm.setEnglish(Integer.parseInt(csvDate[4]));**
62
64
 
63
65
  list.add(tpm);
64
66
 

1

modelのデータがintになっていなかった

2020/12/05 09:40

投稿

w30P9ZaR25lAQGo
w30P9ZaR25lAQGo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -100,7 +100,7 @@
100
100
 
101
101
  public class TestPointModel {
102
102
 
103
- private double nationalLanguage;
103
+ private int nationalLanguage;
104
104
 
105
105
  private int math;
106
106