導航:首頁 > 編程語言 > 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打斷點相關的資料

熱點內容
python直接退出程序 瀏覽:842
百戰程序員收費標准 瀏覽:776
時鍾置換演算法指針變化規則 瀏覽:245
微信加密能否改密碼 瀏覽:104
android許可權組 瀏覽:169
2017單片機 瀏覽:476
讓孩子感興趣編程的電影 瀏覽:261
用顏料製作脆皮解壓球 瀏覽:932
火箭解壓器 瀏覽:72
cnet中級程序員面試題 瀏覽:190
單片機怎麼做人臉識別 瀏覽:154
監獄辦理工商銀行app怎麼辦呢 瀏覽:819
c語言寫編程時需要用什麼輸入法 瀏覽:590
生發程序員 瀏覽:167
高考英語pdf 瀏覽:418
哈利波特忘記伺服器怎麼辦 瀏覽:824
怎麼看其他電腦共享文件夾 瀏覽:513
py文件夾後綴 瀏覽:723
你對我們的app有什麼建議 瀏覽:584
phpgetcookie 瀏覽:145