2017-04-20 114 views
-2
for (Point point : landmarks) 
{ 
    for (int i = 48; i <= 66; i++) 
    { 
     point = landmarks.get(i); 
     //Log.d(TAG,"landmarks (" + landmarks.get(i) +")"); 
     int pointX = (int) (point.x * resizeRatio); 
     int pointY = (int) (point.y * resizeRatio); 

     Log.d(TAG,"My points:(" + pointX +","+ pointY +")"); 

     point=landmarks.get(i+1); 

     int pointXX = (int) (point.x * resizeRatio); 
     int pointYY = (int) (point.y * resizeRatio); 

     canvas.drawLine(pointX, pointY, pointXX, pointYY, mFaceLandmardkPaint); 
    } 
} 

從上面的代碼我必須訪問整數值到變量,pointX和pointY.How可以在必須將這些值存儲到一個文件?將整數值存儲到文件中

+0

您搜索到_how在第一檔中的數據寫入?網上有足夠的教程。 – AxelH

+0

String lipfile =「lip-data」; FileOutputStream fout = new FileOutputStream(「/ sdcard /」+ lipfile +「。txt」);嘗試{fout.write(65); //fout.write(pointX); catch(IOException e){ e.printStackTrace(); }。使用此代碼數據將文件寫入爲「A」。該符號代表ASCII值65. – Ammu

+0

因此,您可以在一個文件中寫入,這是什麼問題? – AxelH

回答

0

嘗試

try{ 
    PrintWriter writer = new PrintWriter("the-file-name.txt", "UTF-8"); 

    for (int i = 48; i <= 66; i++) 
    { 
     point = landmarks.get(i); 
     //Log.d(TAG,"landmarks (" + landmarks.get(i) +")"); 
     int pointX = (int) (point.x * resizeRatio); 
     int pointY = (int) (point.y * resizeRatio); 

     Log.d(TAG,"My points:(" + pointX +","+ pointY +")"); 

     point=landmarks.get(i+1); 

     int pointXX = (int) (point.x * resizeRatio); 
     int pointYY = (int) (point.y * resizeRatio); 

     canvas.drawLine(pointX, pointY, pointXX, pointYY, mFaceLandmardkPaint); 

     writer.println(pointX + ",+ pointY + ","+pointXX+","+pointYY); 
    } 


    writer.close(); 
} catch (IOException e) { 
    // do something 
} 
+0

我試過這個,但沒有得到任何答案。 – Ammu