Java byte stream and character stream including the stream, byte stream through the IO device to read bytes of data the way, while the character stream is read into the data through the byte stream into a character "flow" in the form of user-driven.
Flow through the expansion of packaging functions, such as BufferedStream, can buffer streams, improve reading performance, in fact, are based in Java, this operation IO's.
But we can not BufferedStream is actually available as a stream, in fact, they must be packing a representative of the real IO stream users to operate equipment, such as System.in and System.out, or arrays and strings (another package's stream ).
InputStream can be used for example:
InputStream in = new BufferedInputStream (new BufferedInputStream (System.in));
The character stream it?
In fact, no real character in the form of flow only through the packaging of some special characters in the input stream to carry out operations, such as packing a byte stream InputStream:
Reader reader = new InputStreamReader (System.in);
Suppose, for example packaging the character array:
char [] in = new char [1024];
Reader reader = new CharArrayReader (in);
Understand, the law can understand the flow of operation.
Script is to use a particular description language, based on the format of a certain executable file, also called macro or batch file. At the same time, "script" is the term writer term, the story form is called the script.
星期六, 八月 21, 2010
Oracle Java processing in the user-defined types
Java for PL / SQL in the package does not define the type of support (not found, throw exception invalid name pattern information), need to define schema-level type.
Oracle's API:
Code:
Schema Level Type:
create or replace type Guy as object
(
name varchar2 (50),
age number
)
create or replace type GUYS as Table of GUY
PL / SQL:
create or replace package ArrayNesta is
PROCEDURE insert_guys (
guys_in IN guys
);
end ArrayNesta;
create or replace package body ArrayNesta is
PROCEDURE insert_guys (
guys_in IN guys
)
IS
BEGIN
for i in guys_in.first .. guys_in.last
LOOP
insert into ASSOCIATEARRAYNESTA (name, age) values (guys_in (i). name, guys_in (i). age);
END LOOP;
END insert_guys;
end ArrayNesta;
Database Table:
create table ASSOCIATEARRAYNESTA (
name varchar2 (50),
age number
)
Java:
/ **
*
* /
package array;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import oracle.jdbc.pool.OracleDataSource;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
/ **
* @ Author nfeng
*
* /
public class ArrayTest (
/ **
* @ Param args
* /
public static void main (String [] args) throws Exception (
OracleDataSource ods = new OracleDataSource ();
ods.setURL ("jdbc: oracle: thin: username / password @ host: port: database");
Connection conn = ods.getConnection ();
System.out.println (conn);
StructDescriptor sd = StructDescriptor.createDescriptor ("GUY", conn);
Object [] nesta = new Object [] ("nesta", 29);
STRUCT snesta = new STRUCT (sd, conn, nesta);
Object [] kisey = new Object [] ("kisey", 30);
STRUCT skisey = new STRUCT (sd, conn, kisey);
ArrayDescriptor ad = ArrayDescriptor.createDescriptor ("GUYS", conn);
ARRAY guysin = new ARRAY (ad, conn, new STRUCT [] (snesta, skisey));
CallableStatement cs = conn.prepareCall ("(call ArrayNesta.insert_guys (?))");
cs.setArray (1, guysin);
cs.execute ();
conn.close ();
)
)
Oracle's API:
Code:
Schema Level Type:
create or replace type Guy as object
(
name varchar2 (50),
age number
)
create or replace type GUYS as Table of GUY
PL / SQL:
create or replace package ArrayNesta is
PROCEDURE insert_guys (
guys_in IN guys
);
end ArrayNesta;
create or replace package body ArrayNesta is
PROCEDURE insert_guys (
guys_in IN guys
)
IS
BEGIN
for i in guys_in.first .. guys_in.last
LOOP
insert into ASSOCIATEARRAYNESTA (name, age) values (guys_in (i). name, guys_in (i). age);
END LOOP;
END insert_guys;
end ArrayNesta;
Database Table:
create table ASSOCIATEARRAYNESTA (
name varchar2 (50),
age number
)
Java:
/ **
*
* /
package array;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import oracle.jdbc.pool.OracleDataSource;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
/ **
* @ Author nfeng
*
* /
public class ArrayTest (
/ **
* @ Param args
* /
public static void main (String [] args) throws Exception (
OracleDataSource ods = new OracleDataSource ();
ods.setURL ("jdbc: oracle: thin: username / password @ host: port: database");
Connection conn = ods.getConnection ();
System.out.println (conn);
StructDescriptor sd = StructDescriptor.createDescriptor ("GUY", conn);
Object [] nesta = new Object [] ("nesta", 29);
STRUCT snesta = new STRUCT (sd, conn, nesta);
Object [] kisey = new Object [] ("kisey", 30);
STRUCT skisey = new STRUCT (sd, conn, kisey);
ArrayDescriptor ad = ArrayDescriptor.createDescriptor ("GUYS", conn);
ARRAY guysin = new ARRAY (ad, conn, new STRUCT [] (snesta, skisey));
CallableStatement cs = conn.prepareCall ("(call ArrayNesta.insert_guys (?))");
cs.setArray (1, guysin);
cs.execute ();
conn.close ();
)
)
During the running of Java
[Other Languages]
1. Source code into binary code after compile
2. Implementation of the binary code: OS load the file into memory and execution
[Java]
1. Source code made by the javac compile into a byte code
2. Implementation of the java ClassName:
a. OS first java.exe load into memory and perform, create JVM
b. The java.exe into the parameters dealing with the implementation of the times, so JVM interpretation processing
ClassName content and present them.
1. Source code into binary code after compile
2. Implementation of the binary code: OS load the file into memory and execution
[Java]
1. Source code made by the javac compile into a byte code
2. Implementation of the java ClassName:
a. OS first java.exe load into memory and perform, create JVM
b. The java.exe into the parameters dealing with the implementation of the times, so JVM interpretation processing
ClassName content and present them.
JAVA properties file to read one of
JAVA third method to read the configuration file is:
The first reading of XML
The second reading of INI
Now consider reading this document
package temp;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Test (
public static void main (String [] args) (
String config = "dbconfig.properties"; / / specify the configuration file to read
Properties prop = new Properties ();
InputStream is;
try (
is = new FileInputStream (config);
prop.load (is);
) Catch (FileNotFoundException e) (
System.out.println ("can not find the specified configuration file.");
e.printStackTrace ();
) Catch (IOException e) (
e.printStackTrace ();
)
/ / Here is the specific information read the configuration file
String driver = prop.getProperty ("driver");
System.out.print (driver);
)
)
Properties of our file on this: F: \ Symposium \ java and the configuration file summary \ ConfigSecond directory.
The first reading of XML
The second reading of INI
Now consider reading this document
package temp;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Test (
public static void main (String [] args) (
String config = "dbconfig.properties"; / / specify the configuration file to read
Properties prop = new Properties ();
InputStream is;
try (
is = new FileInputStream (config);
prop.load (is);
) Catch (FileNotFoundException e) (
System.out.println ("can not find the specified configuration file.");
e.printStackTrace ();
) Catch (IOException e) (
e.printStackTrace ();
)
/ / Here is the specific information read the configuration file
String driver = prop.getProperty ("driver");
System.out.print (driver);
)
)
Properties of our file on this: F: \ Symposium \ java and the configuration file summary \ ConfigSecond directory.
星期六, 八月 14, 2010
python quick sort Code:
def quick_sort(ls):
return [] if ls == [] else quick_sort([y for y in ls[1:] if y < ls[0]]) + [ls[0]] + quick_sort([y for y in ls[1:] if y >= ls[0]])
if __name__ == '__main__':
l1 = [3,56,8,1,34,56,89,234,56,231,45,90,33,66,88,11,22]
l2 = quick_sort(l1)
print l1
print l2
return [] if ls == [] else quick_sort([y for y in ls[1:] if y < ls[0]]) + [ls[0]] + quick_sort([y for y in ls[1:] if y >= ls[0]])
if __name__ == '__main__':
l1 = [3,56,8,1,34,56,89,234,56,231,45,90,33,66,88,11,22]
l2 = quick_sort(l1)
print l1
print l2
python3.0 dictionary key order
In fact, the dictionary object that is key - the value of the following is a dictionary object to add, modify, delete (modify and add the same way, when the key does not exist when the value added)
IDLE 3.0
>>> Dic = ("aa": 1, "bb": 2, "ab": 3)
>>> Dic
('Aa': 1, 'ab': 3, 'bb': 2)
>>> For k in sorted (dic.keys ()):
print (k)
aa
ab
-----------------------------------------------
In fact, the dictionary object that is key - value pairs
The following is a dictionary object to add, modify, delete
(Modify and add the same way, when the key does not exist when the value added)
>>> Dic ["cc"] = 4
>>> Dic
('Aa': 1, 'cc': 4, 'ab': 3, 'bb': 2)
>>> Dic ["bc"] = 5
>>> Dic
('Aa': 1, 'cc': 4, 'ab': 3, 'bb': 2, 'bc': 5)
>>> Dic ["cc"] = 6
>>> Dic
('Aa': 1, 'cc': 6, 'ab': 3, 'bb': 2, 'bc': 5)
>>> Del dic ["cc"]
>>> Dic
('Aa': 1, 'ab': 3, 'bb': 2, 'bc': 5)
IDLE 3.0
>>> Dic = ("aa": 1, "bb": 2, "ab": 3)
>>> Dic
('Aa': 1, 'ab': 3, 'bb': 2)
>>> For k in sorted (dic.keys ()):
print (k)
aa
ab
-----------------------------------------------
In fact, the dictionary object that is key - value pairs
The following is a dictionary object to add, modify, delete
(Modify and add the same way, when the key does not exist when the value added)
>>> Dic ["cc"] = 4
>>> Dic
('Aa': 1, 'cc': 4, 'ab': 3, 'bb': 2)
>>> Dic ["bc"] = 5
>>> Dic
('Aa': 1, 'cc': 4, 'ab': 3, 'bb': 2, 'bc': 5)
>>> Dic ["cc"] = 6
>>> Dic
('Aa': 1, 'cc': 6, 'ab': 3, 'bb': 2, 'bc': 5)
>>> Del dic ["cc"]
>>> Dic
('Aa': 1, 'ab': 3, 'bb': 2, 'bc': 5)
Python Developer Activex component method
Python strong feature is that it omnipotent.
Use the win32com module development window ActiveX example: (If you have not installed win32com module, then go to http://python.net/crew/skippy/win32/Downloads.html download).
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
_reg_clsid_ = "(A6688635-62F5-41cb-AF54-CBA84C2F0F86)"
def SplitString (self, val):
return "Hello world", val
if __name__ == '__main__':
print "Registering COM server ..."
import win32com.server.register
win32com.server.register.UseCommandLine (PythonUtilities)
In the console run: python SimpleCOMServer.py
In the HTML page to call the Activex component:
window.onload = function () (
var obj = new ActiveXObject ("Python.Utilities");
alert (obj.SplitString ("Hel"));
)
Use the win32com module development window ActiveX example: (If you have not installed win32com module, then go to http://python.net/crew/skippy/win32/Downloads.html download).
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
_reg_clsid_ = "(A6688635-62F5-41cb-AF54-CBA84C2F0F86)"
def SplitString (self, val):
return "Hello world", val
if __name__ == '__main__':
print "Registering COM server ..."
import win32com.server.register
win32com.server.register.UseCommandLine (PythonUtilities)
In the console run: python SimpleCOMServer.py
In the HTML page to call the Activex component:
window.onload = function () (
var obj = new ActiveXObject ("Python.Utilities");
alert (obj.SplitString ("Hel"));
)
星期三, 八月 11, 2010
Basic Introduction Script
Script is an extension of the batch file is a plain text stored procedures, in general, a computer script is to determine the range of motion control computer to a combination of computing operations, which can be achieved in some other branch of logic.
The script is simply the text of a command section, these text commands can be seen (if you can use Notepad to open to view, edit), the script program in execution, is by the system of an interpreter, the first roads of translated into machine instructions can be identified, according to the order execution process. Because the script is more a time in the implementation of the translation process, so the efficiency than the binary number to be slightly lower.
Script usually called by the application and implementation of the interim. Is widely used in various scripts web design, because the script can not only reduce the page size and improve the web browsing speed, but also enrich the performance of web pages, such as animation, sound and so on. Take the most common example, when clicking the Email address of the page is called automatically when Outlook Express or Foxmail such mail software, is achieved through scripting. Precisely because of these characteristics the script, often used by people with ulterior motives. For example, in the script to add some damage computer systems of command, so when a user when browsing the web, once called this type of script that will enable users of the system under attack. Therefore, users should visit the web page based on the level of confidence selected security level, especially for those who are on the illegal web content, not easily allow the use of scripts. Through the "Security Settings" dialog box, select "Script" option under the various settings you can easily disable and enable on the script.
The script is simply the text of a command section, these text commands can be seen (if you can use Notepad to open to view, edit), the script program in execution, is by the system of an interpreter, the first roads of translated into machine instructions can be identified, according to the order execution process. Because the script is more a time in the implementation of the translation process, so the efficiency than the binary number to be slightly lower.
Script usually called by the application and implementation of the interim. Is widely used in various scripts web design, because the script can not only reduce the page size and improve the web browsing speed, but also enrich the performance of web pages, such as animation, sound and so on. Take the most common example, when clicking the Email address of the page is called automatically when Outlook Express or Foxmail such mail software, is achieved through scripting. Precisely because of these characteristics the script, often used by people with ulterior motives. For example, in the script to add some damage computer systems of command, so when a user when browsing the web, once called this type of script that will enable users of the system under attack. Therefore, users should visit the web page based on the level of confidence selected security level, especially for those who are on the illegal web content, not easily allow the use of scripts. Through the "Security Settings" dialog box, select "Script" option under the various settings you can easily disable and enable on the script.
Script-related language
Scripting language is more and more, the implementation of the general script Yu Yan's interpretation only with the implementation of specific device Youguan, Suoyizhiyao Ji Tong Shang has the appropriate language can be explained on cross-Ping Tai Cheng Xu. Script (Script), is to bind and alias contains a collection of such an order, you can save this collection as a separate file and when necessary implement, so you can easily use the CS in. Script can be saved as a suffix named. Cfg file on the cstrike folder, executed in the console type: exec (script file name). Cfg can. Example, a script saved as buys.cfg file, enter in the console: execbuys.cfg you can achieve what we need to functionality. To achieve a command as long as the definition of the process (alias) is good, and assign a key position for this command, as long as the press after the distribution of good key position, you can achieve this process. All the scripts are achieved through this method.
Common scripting languages: Scala, JavaScript, VBScript, ActionScript, MAX Script, ASP, JSP, PHP, SQL, Perl, Shell, python, Ruby, JavaFX, Lua, AutoIt so.
Common scripting languages: Scala, JavaScript, VBScript, ActionScript, MAX Script, ASP, JSP, PHP, SQL, Perl, Shell, python, Ruby, JavaFX, Lua, AutoIt so.
The main characteristics of the script
Grammar and structures are often relatively simple
Usually relatively simple to learn and use
Usually easy to modify the program's "interpretation" as the operation mode, without the need to "compile"
Capacity development program is better than running performance
Usually relatively simple to learn and use
Usually easy to modify the program's "interpretation" as the operation mode, without the need to "compile"
Capacity development program is better than running performance
VBS off network shutdown automatically after 30 seconds
Just run it after the cable is pulled out once, then automatically shut down immediately into the countdown, "-t 30" is the countdown of the time, you can make their own adjustments.
Code:
Dim Wsh, objWMIService, colMonitoredEvents
Set Wsh = WScript.CreateObject ("WScript.Shell")
Set objWMIService = GetObject ("winmgmts: \. Ootwmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery ("Select * from MSNdis_StatusMediaDisconnect")
Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wsh.run "shutdown-s-t 30-c" & chr (34) & "Network disconnected, the machine will close" & chr (34)
Loop
Code:
Dim Wsh, objWMIService, colMonitoredEvents
Set Wsh = WScript.CreateObject ("WScript.Shell")
Set objWMIService = GetObject ("winmgmts: \. Ootwmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery ("Select * from MSNdis_StatusMediaDisconnect")
Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wsh.run "shutdown-s-t 30-c" & chr (34) & "Network disconnected, the machine will close" & chr (34)
Loop
QueryCode.vbs text file encoded query tool
Just download this file after you can query the.
The following is a detailed code as follows:
'QueryCode.vbs BY: fastslz
'Support for batch queries, you can extend applications on SendTo
set files = WScript.Arguments
if files.Count = 0 Then
MsgBox "Please check the file to drag into this file!", VbInformation, "File encoded query tool BY: fastslz"
end if
for i = 0 To files.Count-1
file = files (i)
Call CheckCode ("encoded:")
next
Function CheckCode (Usage)
Dim slz
set slz = CreateObject ("Adodb.Stream")
slz.Type = 1
slz.Mode = 3
slz.Open
slz.Position = 0
slz.Loadfromfile file
Bin = slz.read (2)
if AscB (MidB (Bin, 1,1)) = & HEF and AscB (MidB (Bin, 2,1)) = & HBB Then
Codes = "UTF-8"
elseif AscB (MidB (Bin, 1,1)) = & HFF and AscB (MidB (Bin, 2,1)) = & HFE Then
Codes = "Unicode"
else
Codes = "GB2312"
end if
WScript.echo file, Usage, Codes
slz.Close
set slz = Nothing
End Function
The following is a detailed code as follows:
'QueryCode.vbs BY: fastslz
'Support for batch queries, you can extend applications on SendTo
set files = WScript.Arguments
if files.Count = 0 Then
MsgBox "Please check the file to drag into this file!", VbInformation, "File encoded query tool BY: fastslz"
end if
for i = 0 To files.Count-1
file = files (i)
Call CheckCode ("encoded:")
next
Function CheckCode (Usage)
Dim slz
set slz = CreateObject ("Adodb.Stream")
slz.Type = 1
slz.Mode = 3
slz.Open
slz.Position = 0
slz.Loadfromfile file
Bin = slz.read (2)
if AscB (MidB (Bin, 1,1)) = & HEF and AscB (MidB (Bin, 2,1)) = & HBB Then
Codes = "UTF-8"
elseif AscB (MidB (Bin, 1,1)) = & HFF and AscB (MidB (Bin, 2,1)) = & HFE Then
Codes = "Unicode"
else
Codes = "GB2312"
end if
WScript.echo file, Usage, Codes
slz.Close
set slz = Nothing
End Function
订阅:
博文 (Atom)