-
Recent Posts
- Hwarang Spirit
- Alchemy
- ListView minHeight, typeface
- Clear All Lint Markers Errors
- android.permission.INTERNET
- eclipse Korean character problem
- OnItemCLickListener not working gridview
- G is G!
- Eclipse shortcut to comment selection in an XML file
- android.app.activitythread.performlaunchactivity nullpointerexception
- How to uninstall Windows Live Essentials via CMD line parameter
- vi fold method
- android.os.NetworkOnMainThreadException
- android socket
- socket2
Tags
Archives
Tag Archives: java
socket2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
public static void main(String args[]) { String ip = "192.168.0.2"; int port = 8080; Socket socket = null; OutputStream os = null; OutputStreamWriter osw = null; Socket socket2 = new Socket(); SocketAddress sock_addr = new InetSocketAddress(ip, port); try { socket2.connect(sock_addr); } catch (UnknownHostException ue) { } catch (IOException ie) { } try { os = socket2.getOutputStream(); osw = new OutputStreamWriter(os); } catch (IOException ie) { } String data = "I love you"; try { osw.write(data, 0, data.length()); osw.flush(); } catch (IOException ie) { } } |
Java Source Structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== |
java int to string
1 2 3 |
int n = 1; String str = String.valueOf(n); |
source compile, class execute
1 |
$ javac filename.java <- compile |
filename.class
1 |
$ java filename <- execute |
java cygwin .configure
JDK Download -> http://www.oracle.com/technetwork/java/javase/downloads/ JDK Install Save as .configure
1 2 3 4 5 |
# JAVA_HOME export set JAVA_HOME=/cygdrive/c/Program\ Files/Java/jdk1.7.0_21/ # PATH export PATH=$PATH:/cygdrive/c/Program\ Files/Java/jdk1.7.0_21/bin/ |