Skip to content

Commit cc51aac

Browse files
committed
add Cell
1 parent 1e2e752 commit cc51aac

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

src/main/java/Cell.java

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import com.google.common.collect.Lists;
2+
3+
import java.util.List;
4+
5+
public class Cell {
6+
public static void main(String[] args) throws InterruptedException {
7+
List<String> cells = Lists.newArrayList();
8+
cells.add("o");
9+
10+
int i=1;
11+
do {
12+
System.out.println("round=" + i);
13+
14+
print(cells);
15+
round(cells);
16+
17+
System.out.println("");
18+
Thread.sleep(1000);
19+
i++;
20+
} while (true);
21+
}
22+
23+
private static void round(List<String> cells) {
24+
int size = cells.size();
25+
for (int i=0; i<size; i++) {
26+
if ("o".equals(cells.get(i))) {
27+
cells.set(i, "O");
28+
} else if ("O".equals(cells.get(i))) {
29+
cells.set(i, "8");
30+
} else if ("8".equals(cells.get(i))) {
31+
cells.set(i, "o");
32+
cells.add("o");
33+
}
34+
}
35+
}
36+
37+
private static void print(List<String> cells) {
38+
for (String cell : cells) {
39+
System.out.print(cell);
40+
}
41+
42+
}
43+
}

src/main/java/Mail.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.Properties;
77

88
public class Mail {
9-
public static void main(String[] args) throws MessagingException, ParseException {
9+
public static void main(String[] args) throws MessagingException, ParseException, InterruptedException {
1010
// ex) --host=mail.test.com --port=25 [email protected] [email protected]
1111

1212
Options options = new Options();
@@ -48,6 +48,10 @@ public static void main(String[] args) throws MessagingException, ParseException
4848
props.put("mail.smtp.host", host);
4949
props.put("mail.smtp.port", port);
5050
props.put("mail.smtp.ssl.protocols", "SSLv2Hello SSLv3");
51+
// props.put("mail.smtp.ssl.protocols", "SSLv2Hello TLSv1"); // 서버 SSLv3 지원 안 할 때 성공
52+
// props.put("mail.smtp.ssl.protocols", "SSLv3");
53+
// props.put("mail.smtp.ssl.protocols", "TLSv1");
54+
5155

5256
Session session = Session.getDefaultInstance(props, null);
5357
session.setDebug(true);
@@ -67,6 +71,8 @@ public static void main(String[] args) throws MessagingException, ParseException
6771
transport.connect();
6872

6973
transport.sendMessage(message, message.getAllRecipients());
74+
75+
Thread.sleep(10000);
7076
transport.close();
7177
}
7278
}

src/main/java/SocketTest.java

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import com.sun.mail.util.LineInputStream;
2+
import com.sun.mail.util.LineOutputStream;
3+
import org.apache.commons.cli.*;
4+
5+
import javax.mail.Message;
6+
import javax.mail.MessagingException;
7+
import javax.mail.Session;
8+
import javax.mail.Transport;
9+
import javax.mail.internet.InternetAddress;
10+
import javax.mail.internet.MimeMessage;
11+
import java.io.BufferedInputStream;
12+
import java.io.BufferedOutputStream;
13+
import java.io.IOException;
14+
import java.net.InetSocketAddress;
15+
import java.net.Socket;
16+
import java.util.Properties;
17+
18+
public class SocketTest {
19+
public static void main(String[] args) throws MessagingException, ParseException, InterruptedException, IOException {
20+
String hostname = "wwl1726.daum.net";
21+
int port = 4240;
22+
23+
Socket socket = new Socket();
24+
socket.connect(new InetSocketAddress(hostname, port), 1 * 1000);
25+
26+
LineInputStream in = new LineInputStream(new BufferedInputStream(socket.getInputStream()));
27+
LineOutputStream out = new LineOutputStream(new BufferedOutputStream(socket.getOutputStream()));
28+
29+
String line = in.readLine();
30+
System.out.println(line);
31+
32+
}
33+
}

0 commit comments

Comments
 (0)