Skip to content

Commit 5329c24

Browse files
authored
Create MixedContent.java
1 parent e9917b9 commit 5329c24

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Easy-Level/MixedContent.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.io.*;
2+
import java.lang.reflect.Array;
3+
import java.util.ArrayList;
4+
5+
public class Main {
6+
7+
public static void main (String[] args) throws IOException {
8+
File file = new File(args[0]);
9+
BufferedReader br = new BufferedReader(new FileReader(file));
10+
String line;
11+
while ((line = br.readLine()) != null) {
12+
ArrayList<String> a1 = new ArrayList<String>();
13+
ArrayList<String> a2 = new ArrayList<String>();
14+
String[] b = line.split(",");
15+
for (String c : b) {
16+
if (c.matches("[0-9]+")) {
17+
a1.add(c);
18+
}
19+
else {
20+
a2.add(c);
21+
}
22+
}
23+
System.out.print(a2.toString().replace("[", "").replace("]", "").replace(" ", ""));
24+
if (!(a2.isEmpty() || a1.isEmpty())) System.out.print("|");
25+
System.out.print(a1.toString().replace("[", "").replace("]", "").replace(" ", ""));
26+
System.out.println();
27+
}
28+
29+
br.close();
30+
}
31+
}

0 commit comments

Comments
 (0)