質問編集履歴

8

2018/06/28 05:55

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -154,7 +154,7 @@
154
154
 
155
155
 
156
156
 
157
- // 以降エラーを省略
157
+ // 以降エラー処理を省略
158
158
 
159
159
 
160
160
 
@@ -167,10 +167,6 @@
167
167
  // Cは早いので省略
168
168
 
169
169
  ```
170
-
171
-
172
-
173
- 基本的にPythonのコードと同じでファイル読み書き、正規表現、16進数ファイル生成などしかしていません。
174
170
 
175
171
 
176
172
 

7

2018/06/28 05:55

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -120,7 +120,7 @@
120
120
 
121
121
  replaceAfter = (line.split(" ", -1))[0];
122
122
 
123
- String outFName = Integer.toHex String(rd.nextInt());
123
+ String outFName = Integer.toHexString(rd.nextInt());
124
124
 
125
125
  out = Paths.get(outFName.toUpperCase());
126
126
 
@@ -128,13 +128,13 @@
128
128
 
129
129
  if(!Files.exists(out)) Files.createFile(out);
130
130
 
131
- catch(IOException e){
131
+ } catch(IOException e){
132
132
 
133
133
  throw e;
134
134
 
135
135
  }
136
136
 
137
- try( BufferedWriter Out = Files.newBufferedWriter(out, Standard Charsets.UTF-8,StandardOpenOption.APPEND); BufferedReader Que = Files.newBufferedReader(que,StandardCharSets.UTF-8)) {
137
+ try(BufferedWriter Out = Files.newBufferedWriter(out, Standard Charsets.UTF-8,StandardOpenOption.APPEND); BufferedReader Que = Files.newBufferedReader(que,StandardCharSets.UTF-8)) {
138
138
 
139
139
  for(String cline; (cline = Que.readLine()) != null;) {
140
140
 

6

2018/06/28 05:31

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -106,9 +106,11 @@
106
106
 
107
107
  Path que = Paths.get(args[3]);
108
108
 
109
- Random rd = new Secure Random();
109
+ Random rd = new SecureRandom();
110
110
 
111
111
  String replaceAfter = "";
112
+
113
+ String keyword = "key";
112
114
 
113
115
 
114
116
 

5

2018/06/28 04:45

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -96,25 +96,73 @@
96
96
 
97
97
 
98
98
 
99
- // ...いろいろ省略
99
+
100
100
 
101
101
 
102
102
 
103
103
  Path in = Paths.get(args[1]);
104
104
 
105
- Path out = Paths.get(args[2]);
105
+ Path out = null;
106
106
 
107
107
  Path que = Paths.get(args[3]);
108
108
 
109
+ Random rd = new Secure Random();
109
110
 
110
-
111
- try(BufferedReader In = Files.newBufferedReader(in,...省略)
111
+ String replaceAfter = "";
112
112
 
113
113
 
114
114
 
115
+ try(BufferedReader In = Files.newBufferedReader(in,StandardCharSets.UTF-8)){
116
+
117
+ for(String line; (line = In.readLine()) != null;) {
118
+
119
+ replaceAfter = (line.split(" ", -1))[0];
120
+
121
+ String outFName = Integer.toHex String(rd.nextInt());
122
+
123
+ out = Paths.get(outFName.toUpperCase());
124
+
125
+ try {
126
+
127
+ if(!Files.exists(out)) Files.createFile(out);
128
+
129
+ catch(IOException e){
130
+
131
+ throw e;
132
+
133
+ }
134
+
135
+ try( BufferedWriter Out = Files.newBufferedWriter(out, Standard Charsets.UTF-8,StandardOpenOption.APPEND); BufferedReader Que = Files.newBufferedReader(que,StandardCharSets.UTF-8)) {
136
+
137
+ for(String cline; (cline = Que.readLine()) != null;) {
138
+
139
+ if(cline.indexOf(keyword) != -1) {
140
+
141
+ Out.append(cline.replace(keyword, replaceAfter);
142
+
115
- // 省略
143
+ Out.newLine();
144
+
145
+ else {
146
+
147
+ Out.append(cline);
148
+
149
+ Out.newLine();
150
+
151
+ }
116
152
 
117
153
 
154
+
155
+ // 以降エラーを省略
156
+
157
+
158
+
159
+ ```
160
+
161
+
162
+
163
+ ```c
164
+
165
+ // Cは早いので省略
118
166
 
119
167
  ```
120
168
 

4

2018/06/28 04:40

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -70,7 +70,7 @@
70
70
 
71
71
  if cline.find(key) != -1:
72
72
 
73
- Out.write(cline.replace(replaceStr, line.split(",")[0]))
73
+ Out.write(cline.replace(keyword, line.split(",")[0]))
74
74
 
75
75
  else:
76
76
 

3

2018/06/28 04:13

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -130,7 +130,7 @@
130
130
 
131
131
  c real 0m0.002s
132
132
 
133
- java real 0m0.150s
133
+ java real 0m0.150s
134
134
 
135
135
  python real 0m0.013s
136
136
 
@@ -144,4 +144,4 @@
144
144
 
145
145
 
146
146
 
147
- ご教授をお願い致します。
147
+ どなたかご教授をお願い致します。

2

2018/06/28 04:08

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
File without changes
test CHANGED
@@ -54,9 +54,9 @@
54
54
 
55
55
 
56
56
 
57
- 内容: createtime=yyyymmddlocalHost=...みたいなサーバ名とかがぐちゃーってある
57
+ 内容: createtime=yyyymmddlocalHost=...みたいなサーバ名とかがぐちゃーって書いてある
58
58
 
59
- この中のkeyという項目を書き換えてファイルに書き出す
59
+ この中のkeyという文字列書き換えて16進数ファイルに書き出す
60
60
 
61
61
  """
62
62
 
@@ -128,9 +128,9 @@
128
128
 
129
129
 
130
130
 
131
- c real 0m0.002s
131
+ c real 0m0.002s
132
132
 
133
- java real 0m0.150s
133
+ java real 0m0.150s
134
134
 
135
135
  python real 0m0.013s
136
136
 
@@ -140,7 +140,7 @@
140
140
 
141
141
 
142
142
 
143
- 知識不足なので実行速度の違いが何故こんな出るのか分かりません 汗
143
+ 知識不足なので実行速度の違いが何故こんな出るのか分かりません 汗
144
144
 
145
145
 
146
146
 

1

2018/06/28 04:07

投稿

nobodytolove123
nobodytolove123

スコア61

test CHANGED
@@ -1 +1 @@
1
- ファイル操作にいてJavaがPythonよりも遅い
1
+ ファイル操作にいてJavaがPythonよりも遅い
test CHANGED
File without changes