2013-02-06 2 views
-2

J'ai un problème, j'ai le code source comme celui-cijava fichier renommage avant de les charger

public int uploadFile(String sourceFileUri) { 
    SharedPreferences myPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); 
    String upLoadServerUri = new String(myPref.getString("serverURL", Constants.URL)+"/upload.php"); 
    String fileName = picturePath; 

    HttpURLConnection conn = null; 
    DataOutputStream dos = null; 
    String lineEnd = "\r\n"; 
    String twoHyphens = "--"; 
    String boundary = "*****"; 
    int bytesRead, bytesAvailable, bufferSize; 
    byte[] buffer; 
    int maxBufferSize = 1 * 1024 * 1024; 
    File sourceFile = new File(picturePath); 

Comment renommer le fichier sur PicturePath avant téléchargé. Merci Vous

+0

Probablement 'File # renameTo'! –

+0

duplication possible de [android, Comment renommer un fichier?] (Http://stackoverflow.com/questions/10424997/android-how-to-rename-a-file) – Nate

Répondre

0

Vous pouvez essayer en mettant cela en mendiait de la fonction:

File renamed =new File(sourceFileUri); 
renamed.renameTo(new File("newfile.png")); 

Et vous appellerez renamed.getAbsolutePath(); au lieu de sourceFileUri.

Questions connexes