git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
retrofit from gjexer
[fanfix.git]
/
src
/
jexer
/
demos
/
Demo2.java
diff --git
a/src/jexer/demos/Demo2.java
b/src/jexer/demos/Demo2.java
index 81a458d90057f822570f3e9eea750eb013a7f601..e6112f65da363cac3d2c515506d3ace66e92b6e5 100644
(file)
--- a/
src/jexer/demos/Demo2.java
+++ b/
src/jexer/demos/Demo2.java
@@
-3,7
+3,7
@@
*
* The MIT License (MIT)
*
*
* The MIT License (MIT)
*
- * Copyright (C) 201
6
Kevin Lamonte
+ * Copyright (C) 201
9
Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@
-28,8
+28,12
@@
*/
package jexer.demos;
*/
package jexer.demos;
-import java.net.*;
-import jexer.net.*;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+import jexer.net.TelnetServerSocket;
/**
* This class is the main driver for a simple demonstration of Jexer's
/**
* This class is the main driver for a simple demonstration of Jexer's
@@
-38,32
+42,48
@@
import jexer.net.*;
*/
public class Demo2 {
*/
public class Demo2 {
+ /**
+ * Translated strings.
+ */
+ private static final ResourceBundle i18n = ResourceBundle.getBundle(Demo2.class.getName());
+
/**
* Main entry point.
*
* @param args Command line arguments
*/
public static void main(final String [] args) {
/**
* Main entry point.
*
* @param args Command line arguments
*/
public static void main(final String [] args) {
+ ServerSocket server = null;
try {
if (args.length == 0) {
try {
if (args.length == 0) {
- System.err.print
f("USAGE: java -cp jexer.jar jexer.demos.Demo2 port\n"
);
+ System.err.print
ln(i18n.getString("usageString")
);
return;
}
int port = Integer.parseInt(args[0]);
return;
}
int port = Integer.parseInt(args[0]);
-
ServerSocket
server = new TelnetServerSocket(port);
+ server = new TelnetServerSocket(port);
while (true) {
Socket socket = server.accept();
while (true) {
Socket socket = server.accept();
- System.out.printf("New connection: %s\n", socket);
+ System.out.println(MessageFormat.
+ format(i18n.getString("newConnection"), socket));
DemoApplication app = new DemoApplication(socket.getInputStream(),
socket.getOutputStream());
DemoApplication app = new DemoApplication(socket.getInputStream(),
socket.getOutputStream());
- System.out.printf(" language: %s\n",
+ System.out.println(MessageFormat.
+ format(i18n.getString("language"),
((jexer.net.TelnetInputStream) socket.getInputStream()).
((jexer.net.TelnetInputStream) socket.getInputStream()).
- getLanguage());
+ getLanguage())
)
;
(new Thread(app)).start();
}
} catch (Exception e) {
e.printStackTrace();
(new Thread(app)).start();
}
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ if (server != null) {
+ try {
+ server.close();
+ } catch (Exception e) {
+ // SQUASH
+ }
+ }
}
}
}
}