導航:首頁 > 編程語言 > java打斷點

java打斷點

發布時間:2023-06-26 18:35:10

A. java中如何添加斷點調試

添加斷點測試可以直接在要測試的代碼處,雙擊滑鼠左鍵,出現一個藍色小點,說明添加斷點成功;
接下來是測試,在代碼頁面點擊滑鼠右鍵,選擇debug ->debug as myeclipse/eclipse application。
以debug方式運行java程序後,可以執行以下操作:
(F5)單步執行程序,遇到方法時進入;
(F6)單步執行程序,遇到方法時跳過;
(F7)單步執行程序,從當前方法跳出;
(F8)直接執行程序。遇到斷點時暫停。
另外,在debug時,會有很多有用信息顯示在debug框里,如堆棧信息,需要自己實踐;在程序界面里,滑鼠移到變數上時會有當前變數的屬性值。
可看下參考資料(有圖說明):http://jingyan..com/article/3c343ff700a7fd0d37796320.html。

B. Java編程 如何使用斷點

編譯器不同是不一樣的。
大致原理是
你在某個代碼添加端點後
系統在運行到該代碼的時候會停止。
當你遇到代碼運行時候會中斷操作的時候
採用斷點來分析代碼會在哪個地方停止
簡單的舉例,當你毫無頭緒的時候,把代碼用斷點分成3份,然後檢查代碼停止在哪一份,在將這份細分為3份,最終確定到代碼在哪個語句出錯。
另外
斷點也可以幫你分析異常數據出現的地方,你可以自己設置一些測試數據,通過監視窗口+斷點來監視,確定哪個變數在哪個環節出錯了,最終可以鎖定到一個語句並檢查出問題

C. 用Java實現HTTP斷點續傳功能(2)

//啟動子線程

fileSplitterFetch = new FileSplitterFetch[nStartPos length];

for(int i= ;i<nStartPos length;i++)

{

fileSplitterFetch[i] = new FileSplitterFetch(siteInfoBean getSSiteURL()

siteInfoBean getSFilePath() + File separator + siteInfoBean getSFileName()

nStartPos[i] nEndPos[i] i);

Utility log( Thread + i + nStartPos = + nStartPos[i] + nEndPos = + nEndPos[i]);

fileSplitterFetch[i] start();

}

// fileSplitterFetch[nPos length ] = new FileSplitterFetch(siteInfoBean getSSiteURL()

siteInfoBean getSFilePath() + File separator + siteInfoBean getSFileName() nPos[nPos length ] nFileLength nPos length );

// Utility log( Thread + (nPos length ) + nStartPos = + nPos[nPos length ] +

nEndPos = + nFileLength);

// fileSplitterFetch[nPos length ] start();

//等待子線程結束

//int count = ;

//是否結束while循環

boolean breakWhile = false;

while(!bStop)

{

write_nPos();

Utility sleep( );

breakWhile = true;

for(int i= ;i<nStartPos length;i++)

{

if(!fileSplitterFetch[i] bDownOver)

{

breakWhile = false;

break;

}

}

if(breakWhile)

break;

//count++;

//if(count> )

// siteStop();

}

System err println( 文件下載結束!察姿悶 );

冊哪}

catch(Exception e){e printStackTrace ();}

}

//獲得文件長度

public long getFileSize()

{

int nFileLength = ;

try{

URL url = new URL(siteInfoBean getSSiteURL());

HttpURLConnection Connection = (HttpURLConnection)url openConnection ();

( User Agent NetFox );

int responseCode=();

if(responseCode>= )

{

processErrorCode(responseCode);

return ; // represent access is error

}

String sHeader;

for(int i= ;;i++)

敗彎{

//DataInputStream in = new DataInputStream( ());

//Utility log(in readLine());

sHeader=(i);

if(sHeader!=null)

{

if(sHeader equals( Content Length ))

{

nFileLength = Integer parseInt((sHeader));

break;

}

}

else

break;

}

}

catch(IOException e){e printStackTrace ();}

catch(Exception e){e printStackTrace ();}

Utility log(nFileLength);

return nFileLength;

}

//保存下載信息(文件指針位置)

private void write_nPos()

{

try{

output = new DataOutputStream(new FileOutputStream(tmpFile));

output writeInt(nStartPos length);

for(int i= ;i<nStartPos length;i++)

{

// output writeLong(nPos[i]);

output writeLong(fileSplitterFetch[i] nStartPos);

output writeLong(fileSplitterFetch[i] nEndPos);

}

output close();

}

catch(IOException e){e printStackTrace ();}

catch(Exception e){e printStackTrace ();}

}

//讀取保存的下載信息(文件指針位置)

private void read_nPos()

{

try{

DataInputStream input = new DataInputStream(new FileInputStream(tmpFile));

int nCount = input readInt();

nStartPos = new long[nCount];

nEndPos = new long[nCount];

for(int i= ;i<nStartPos length;i++)

{

nStartPos[i] = input readLong();

nEndPos[i] = input readLong();

}

input close();

}

catch(IOException e){e printStackTrace ();}

catch(Exception e){e printStackTrace ();}

}

private void processErrorCode(int nErrorCode)

{

System err println( Error Code : + nErrorCode);

}

//停止文件下載

public void siteStop()

{

bStop = true;

for(int i= ;i<nStartPos length;i++)

fileSplitterFetch[i] splitterStop();

}

lishixin/Article/program/Java/hx/201311/27070

閱讀全文

與java打斷點相關的資料

熱點內容
腎病pdf 瀏覽:230
網站怎麼用本地伺服器 瀏覽:120
javadoc導入android 瀏覽:517
文件掃描成pdf 瀏覽:696
涼山火災救援命令 瀏覽:54
壓縮機三相檢測 瀏覽:861
linux怎麼安裝光碟 瀏覽:799
寬頻伺服器無響應是為什麼 瀏覽:226
壓縮包內看圖 瀏覽:914
安卓手機如何發現app後台調用情況 瀏覽:561
程序員簡歷工作描述 瀏覽:159
伺服器中強制疾跑的指令是什麼 瀏覽:54
日語命令性 瀏覽:261
免費的程序編譯游戲 瀏覽:892
如何安裝屏蔽的APP 瀏覽:198
豬臉識別app如何下載 瀏覽:156
卓嵐串口伺服器如何使用 瀏覽:440
pdf周振甫 瀏覽:759
程序員35歲生日圖片 瀏覽:629
矩形密封圈的壓縮量 瀏覽:457