質問編集履歴
4
誤字の修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -17,25 +17,21 @@
|
|
|
17
17
|
import java.io.PrintWriter
|
|
18
18
|
|
|
19
19
|
object Main {
|
|
20
|
-
|
|
20
|
+
def main(args: Array[String]): Unit = {// ファイルから読み込み0
|
|
21
|
-
|
|
22
|
-
// ファイルから読み込み0
|
|
23
|
-
|
|
21
|
+
val source =Source.fromFile("C:\Users\xxx\Documents\scala\s.json", "UTF-8")//8行目
|
|
24
|
-
|
|
22
|
+
source.getLines.foreach{
|
|
25
|
-
|
|
23
|
+
line => println(line)
|
|
26
|
-
}
|
|
27
|
-
source.close()
|
|
28
|
-
// 書き込み
|
|
29
|
-
val pw = new PrintWriter("C:\Users\xxx\Documents\scala\t.json")
|
|
30
|
-
pw.write("Hello, world")
|
|
31
|
-
pw.close
|
|
32
24
|
}
|
|
25
|
+
source.close()// 書き込み
|
|
26
|
+
val pw = new PrintWriter("C:\Users\xxx\Documents\scala\t.json")
|
|
27
|
+
pw.write("Hello, world")
|
|
28
|
+
pw.close
|
|
29
|
+
}
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
### 試したこと
|
|
36
32
|
ソースファイルの記述方法が悪いのかと思い、8行目を
|
|
37
|
-
val source = Source.fromFile("s.json, "UTF-8")
|
|
33
|
+
val source = Source.fromFile("s.json", "UTF-8")
|
|
38
|
-
|
|
34
|
+
val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.json", "UTF-8")
|
|
39
35
|
に変更しましたがエラー文が解消されることはありませんでした。
|
|
40
36
|
|
|
41
37
|
scalaは研究室の関係上2.12.1を使用していますが、最新版ではありません。それが原因ではないと思いますが…
|
3
誤字の修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
def main(args: Array[String]): Unit = {
|
|
21
21
|
|
|
22
22
|
// ファイルから読み込み0
|
|
23
|
-
|
|
23
|
+
val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.json", "UTF-8") // Shift_JIS, EUC-JP なども可 //該当の8行目
|
|
24
24
|
source.getLines.foreach{ line =>
|
|
25
25
|
println(line)
|
|
26
26
|
}
|
2
誤字の修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -20,19 +20,11 @@
|
|
|
20
20
|
def main(args: Array[String]): Unit = {
|
|
21
21
|
|
|
22
22
|
// ファイルから読み込み0
|
|
23
|
-
val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.json, "UTF-8") // Shift_JIS, EUC-JP なども可 //該当の8行目
|
|
23
|
+
val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.json", "UTF-8") // Shift_JIS, EUC-JP なども可 //該当の8行目
|
|
24
24
|
source.getLines.foreach{ line =>
|
|
25
25
|
println(line)
|
|
26
26
|
}
|
|
27
27
|
source.close()
|
|
28
|
-
|
|
29
|
-
// URL 指定でインターネットから読み込み
|
|
30
|
-
val source2 = Source.fromURL("http://www.example.com", "UTF-8")
|
|
31
|
-
source2.getLines.foreach{ line =>
|
|
32
|
-
println(line)
|
|
33
|
-
}
|
|
34
|
-
source2.close()
|
|
35
|
-
|
|
36
28
|
// 書き込み
|
|
37
29
|
val pw = new PrintWriter("C:\Users\xxx\Documents\scala\t.json")
|
|
38
30
|
pw.write("Hello, world")
|
1
誤字の修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
def main(args: Array[String]): Unit = {
|
|
21
21
|
|
|
22
22
|
// ファイルから読み込み0
|
|
23
|
-
val source = Source.fromFile("C:\Users\
|
|
23
|
+
val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.json, "UTF-8") // Shift_JIS, EUC-JP なども可 //該当の8行目
|
|
24
24
|
source.getLines.foreach{ line =>
|
|
25
25
|
println(line)
|
|
26
26
|
}
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
source2.close()
|
|
35
35
|
|
|
36
36
|
// 書き込み
|
|
37
|
-
val pw = new PrintWriter("C:\Users\
|
|
37
|
+
val pw = new PrintWriter("C:\Users\xxx\Documents\scala\t.json")
|
|
38
38
|
pw.write("Hello, world")
|
|
39
39
|
pw.close
|
|
40
40
|
}
|