Commit c23c26b05b9104c7509441831b5dd6882642ebf1

Authored by don ago
1 parent 43d0a1e578
Exists in master

지집

Showing 1 changed file with 5 additions and 7 deletions Side-by-side Diff

app/SendLog.scala View file @ c23c26b
1 1 import java.io.OutputStreamWriter
2 2 import java.net.URI
  3 +import java.nio.charset.Charset
3 4 import java.util.zip.GZIPOutputStream
4 5  
5 6 import org.apache.commons.lang.time
6 7  
... ... @@ -29,9 +30,9 @@
29 30  
30 31 httpcon.setDoOutput(true)
31 32 httpcon.setDoInput(true)
32   - var out = httpcon.getOutputStream
33   - var w = new OutputStreamWriter(out)
  33 + var out = new GZIPOutputStream(httpcon.getOutputStream)
34 34  
  35 +
35 36 val clock = new StopWatch()
36 37 clock.start()
37 38 for (a <- 1 to 500000) {
38 39  
39 40  
40 41  
41 42  
... ... @@ -44,19 +45,17 @@
44 45 for (x <- str_array) {
45 46 total_line += 1
46 47 cur_line += 1
47   - w.write(x + "\n")
  48 + out.write(x.getBytes(Charset.forName("UTF8")))
48 49  
49 50  
  51 +
50 52 if (cur_line == rand_val) {
51 53  
52   - w.flush()
53 54  
54   -
55 55 val in = httpcon.getInputStream
56 56 val s = scala.io.Source.fromInputStream(in)("UTF8")
57 57 val r_text = s.mkString
58 58 //println(r_text)
59   - w.close()
60 59 out.close()
61 60 httpcon.disconnect()
62 61  
... ... @@ -68,7 +67,6 @@
68 67 httpcon.setDoOutput(true)
69 68 httpcon.setDoInput(true)
70 69 out = new GZIPOutputStream(httpcon.getOutputStream)
71   - w = new OutputStreamWriter(out)
72 70  
73 71 cur_line = 0
74 72 rand_val = Random.nextInt(3000) + 1