java 生成oracle block(dba 手記2 c++程式改)
java 生成oracle block(dba 手記2 77頁c++程式改)
/**
* @(#)dbblockreadWrite.java
*
* @author lihongjie
* @version 1.00 2011/11/6
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.*;
public class dbblockreadWrite {
/**
* Creates a new instance of dbblockreadWrite
.
*/
public dbblockreadWrite() {
}
/**
* @param args the command line arguments
*/
public static void readWritFileByBytes(String fileName,int Blksiz) {
File file = new File(fileName);
File outFile = new File(fileName+"out");//定義複製目標檔案
InputStream in = null;
FileOutputStream out=null;
BufferedOutputStream bout=null;
try {
// 一次讀多個位元組
byte[] tempbytes = new byte[Blksiz];
byte[] errdbytes = new byte[Blksiz];
byte[] a = HexString2Bytes("ff");
byte[] b = HexString2Bytes("04");
byte[] c = HexString2Bytes("f0");
byte[] d = HexString2Bytes("f0");
errdbytes[14]=a[0];
errdbytes[15]=b[0];
errdbytes[16]=c[0];
errdbytes[17]=d[0];
System.out.println(Bytes2HexString(errdbytes).substring(1,60)); //test。。。
//errdbytes[0]=HexString2Bytes("0f");
int byteread = 0;
in = new FileInputStream(fileName);
int avaibytes=in.available()/8102;
out = new FileOutputStream(outFile);
bout = new BufferedOutputStream(out);
while (((byteread = in.read(tempbytes)) != -1)&& (avaibytes>-1)) {
//System.out.write(tempbytes, 0, byteread);
bout.write(tempbytes, 0, byteread);
if (byteread == -1){
bout.write(errdbytes, 0,Blksiz );//後面引數 該是什麼呢,嘎嘎 位元組數
}
avaibytes--;
}
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
bout.close();
} catch (IOException e1) {
}
}
}
}
public static byte uniteBytes(byte src0, byte src1) {
byte _b0 = Byte.decode("0x" + new String(new byte[]{src0})).byteValue();
_b0 = (byte)(_b0 << 4);
byte _b1 = Byte.decode("0x" + new String(new byte[]{src1})).byteValue();
byte ret = (byte)(_b0 ^ _b1);
return ret;
}
/**
* 將指定字串src,以每兩個字元分割轉換為16進位制形式
* 如:"2B44EFD9" –> byte[]{0x2B, 0×44, 0xEF, 0xD9}
* @param src String
* @return byte[]
*/
public static byte[] HexString2Bytes(String src){
byte[] ret = new byte[src.length()/2];
byte[] tmp = src.getBytes();
for(int i=0; i< tmp.length/2; i++){
ret[i] = uniteBytes(tmp[i*2], tmp[i*2+1]);
}
return ret;
}
/**
*
* @param b byte[]
* @return String
*/
public static String Bytes2HexString(byte[] b) {
String ret = "";
for (int i = 0; i < b.length; i++) {
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
ret += hex.toUpperCase();
}
return ret;
}
public static void main(String[] args) {
readWritFileByBytes( "rac網上所有問題.docx",8192);
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9879835/viewspace-1056190/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 《Oracle DBA手記》- 一書出版Oracle
- Oracle vs PostgreSQL DBA(22)- Oracle VPD#2OracleSQL
- 2_深入解析Oracle ASSM結構之Level 2 Bitmap BlockOracleSSMBloC
- DBA手記-BBED 的說明
- Oracle Block Cleanouts 塊清除OracleBloC
- DBA手記(學習)-library cache pin
- oracle DBA 角色重建Oracle
- 【BLOCK】Oracle 塊管理常用SQLBloCOracleSQL
- Oracle vs PostgreSQL DBA(21)- Oracle VPDOracleSQL
- ListCode增刪改查程式碼生成器-支援java、php、python、nodejsJavaPHPPythonNodeJS
- DBA ORACLE連線操作Oracle
- Oracle DBA的職責Oracle
- c/c++程式碼流程圖生成C++流程圖
- ORACLE DBA必須記住的常用SQL命令和檢視OracleSQL
- 記一次慘敗的Oracle DBA面試經歷Oracle面試
- freemarker 生成 Java 程式碼Java
- oracle DBA 巡檢專案Oracle
- Oracle批次生成Merge指令碼程式Oracle指令碼
- 【BLOCK】Oracle壞塊處理命令參考BloCOracle
- AutoreleasePool、Block、Runloop整理筆記BloCOOP筆記
- iOS Block學習筆記iOSBloC筆記
- C++手寫記憶體池C++記憶體
- 【DBA】Oracle DBA安全之道(規避風險,堅守底線)Oracle
- android層java如何呼叫cocos2dx c++程式碼 步驟AndroidJavaC++
- 成為MySQL DBA後,再看ORACLE資料庫(五、記憶體管理)MySqlOracle資料庫記憶體
- oracle執行java程式碼OracleJava
- 實戰生成對抗網路[2]:生成手寫數字
- DBA手記(學習) – LOGMNR 簡單而強大的工具
- UI2Code智慧生成Flutter程式碼——機器生成程式碼UIFlutter
- Oracle 11g DG新特性--Automatic block repairOracleBloCAI
- oracle生成uuidOracleUI
- Java程式生成linechart report的方法Java
- Oracle dba角色和sysdba的區別Oracle
- C++實現學生成績資訊登記表C++
- C/C++程式設計知識:C++ 快速隨機數生成器C++程式設計隨機
- position:absolute和float隱式改變display為inline-blockinlineBloC
- Oracle11g生成手動的快照報告報錯Oracle
- C++核心程式設計筆記C++程式設計筆記
- Oracle vs PostgreSQL DBA(13)- 拆分(split)分割槽OracleSQL