Code Examplets phần 10 ppt

48 118 0
Code Examplets phần 10 ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Executes a Command try { String command = "ls"; Process child = Runtime.getRuntime().exec(command); } catch (IOException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/89.html [8/1/2000 7:51:07 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Reading Output from a Command try { // Execute command String command = "ls"; Process child = Runtime.getRuntime().exec(command); // Get input stream to read from it InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { process((char)c); } in.close(); } catch (IOException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/90.html [8/1/2000 7:51:07 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Sending Input to a Command try { // Execute command String command = "cat"; Process child = Runtime.getRuntime().exec(command); // Get output stream to write from it OutputStream out = child.getOutputStream(); out.write("some text".getBytes()); out.close(); } catch (IOException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/91.html [8/1/2000 7:51:08 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Pausing try { Thread.sleep(5000); // 5 seconds } catch (InterruptedException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/92.html [8/1/2000 7:51:08 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Getting the Current Time There are two ways of getting the current time. // One way long time = System.currentTimeMillis(); // Another way Date now = new Date(); Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/93.html [8/1/2000 7:51:09 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Getting the Value of a System Property String dir = System.getProperty("user.dir"); Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/94.html [8/1/2000 7:51:09 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Setting the Value of a System Property String previousValue = System.setProperty( "application.property", "newValue"); Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/95.html [8/1/2000 7:51:10 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Using a Thread-local Variable static ThreadLocal tlData = new ThreadLocal(); public void aMethod() { // Retrieve value. Object o = tlData.get(); // Set value. tlData.set(o); } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/96.html [8/1/2000 7:51:10 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Loading Native Code On Windows, loadLibrary(``s'') loads s.dll. On Solaris, it loads s.so. System.loadLibrary("libraryName"); Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/97.html [8/1/2000 7:51:11 AM] java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Converting Unicode to UTF-8 try { String string = "\u5639\u563b"; byte[] utf8 = string.getBytes("UTF8"); } catch (UnsupportedEncodingException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan. Order this book from Amazon [ This page was updated: 19-Jul-2000 ] Products & APIs | Developer Connection | Docs & Training | Online Support Community Discussion | Industry News | Solutions Marketplace | Case Studies Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World FAQ | Feedback | Map | A-Z Index For more information on Java technology and other software from Sun Microsystems, call: (800) 786-7638 Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first. Copyright © 1995-2000 Sun Microsystems, Inc. All Rights Reserved. Terms of Use. Privacy Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/98.html [8/1/2000 7:51:11 AM] [...]... http://developer.java.sun.com/developer/codesamples/java.lang/99.html [8/1/2000 7:51:12 AM] Code Samples from the Java Developers Almanac 2000 java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Determining a Character's Unicode Block char ch = '\u5639'; Character.UnicodeBlock block = Character.UnicodeBlock.of(ch); Examplets TM provided by permission.. .Code Samples from the Java Developers Almanac 2000 java.lang Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Converting UTF-8 to Unicode public static String toUnicode(byte[] utf8buf) { try { return new String(utf8buf, "UTF8"); } catch (UnsupportedEncodingException e) { } return null; } Examplets TM provided by permission... Copyright © 1995-2000 Sun Microsystems, Inc All Rights Reserved Terms of Use Privacy Policy http://developer.java.sun.com/developer/codesamples/java.lang /100 .html [8/1/2000 7:51:12 AM] Code Samples from the Java Developers Almanac 2000 javax.naming Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Creating an Initial Context to the Naming Service... (NamingException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan Order this book from Amazon [ This page was updated: 19-Jul-2000 ] http://developer.java.sun.com/developer/codesamples/javax.naming.directory/297.html (1 of 2) [8/1/2000 7:51:21 AM] Code Samples from the Java Developers Almanac 2000 javax.naming.directory Code Samples Index These code examples... (NamingException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan Order this book from Amazon [ This page was updated: 19-Jul-2000 ] http://developer.java.sun.com/developer/codesamples/javax.naming.directory/298.html (1 of 2) [8/1/2000 7:51:21 AM] Code Samples from the Java Developers Almanac 2000 javax.naming.directory Code Samples Index These code examples... (NamingException e) { } Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan Order this book from Amazon [ This page was updated: 19-Jul-2000 ] http://developer.java.sun.com/developer/codesamples/javax.naming.directory/300.html (1 of 2) [8/1/2000 7:51:23 AM] Code Samples from the Java Developers Almanac 2000 javax.naming.directory Code Samples Index These code examples... Copyright © 1995-2000 Sun Microsystems, Inc All Rights Reserved Terms of Use Privacy Policy http://developer.java.sun.com/developer/codesamples/javax.naming/286.html [8/1/2000 7:51:15 AM] Code Samples from the Java Developers Almanac 2000 javax.naming Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Creating and Destroying a Subcontext in the Naming... Copyright © 1995-2000 Sun Microsystems, Inc All Rights Reserved Terms of Use Privacy Policy http://developer.java.sun.com/developer/codesamples/javax.naming/287.html (1 of 2) [8/1/2000 7:51:16 AM] Code Samples from the Java Developers Almanac 2000 javax.naming Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Getting an Object's Fully Qualified Name... Copyright © 1995-2000 Sun Microsystems, Inc All Rights Reserved Terms of Use Privacy Policy http://developer.java.sun.com/developer/codesamples/javax.naming/288.html [8/1/2000 7:51:16 AM] Code Samples from the Java Developers Almanac 2000 javax.naming Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Using a URL as a Name to the Initial Context... Copyright © 1995-2000 Sun Microsystems, Inc All Rights Reserved Terms of Use Privacy Policy http://developer.java.sun.com/developer/codesamples/javax.naming/289.html [8/1/2000 7:51:17 AM] Code Samples from the Java Developers Almanac 2000 javax.naming Code Samples Index These code examples and other materials are subject to Sun Microsystems, Inc Legal Terms Parsing a Composite Name In the composite name . Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/95.html [8/1/2000 7:51 :10 AM] java.lang Code Samples Index These code. Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang/96.html [8/1/2000 7:51 :10 AM] java.lang Code Samples Index These code. Policy. Code Samples from the Java Developers Almanac 2000 http://developer.java.sun.com/developer/codesamples/java.lang /100 .html [8/1/2000 7:51:12 AM] javax.naming Code Samples Index These code

Ngày đăng: 06/08/2014, 02:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan