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

熱點內容
php社區程序 瀏覽:976
python現在就業怎麼樣 瀏覽:304
php上傳目錄許可權設置 瀏覽:736
php合同檔案管理系統 瀏覽:366
tshock伺服器地址 瀏覽:877
php解析文件流 瀏覽:780
伺服器機箱銅片有什麼用 瀏覽:969
樂視手機如何使用原生態安卓 瀏覽:215
dns伺服器怎麼備份啊 瀏覽:865
蘋果退款app怎麼重新購買 瀏覽:655
U盤cmd檢查文件夾成文件 瀏覽:66
java路徑是否存在 瀏覽:338
新氧app上怎麼測臉型 瀏覽:787
用指令獲得命令方塊 瀏覽:427
流星蝴蝶劍怎麼輸入命令 瀏覽:681
keil有紅叉但是能編譯通過 瀏覽:498
賽拉圖的空調壓縮機多少錢 瀏覽:330
linux54 瀏覽:986
shutdown命令linux 瀏覽:250
編譯的輸入 瀏覽:511