Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem lies in the way you are creating the <code>File</code> <code>source</code>.</p> <p>There is a bug in it that is generating a File with the wrong directory.</p> <p>So when you call <code>.exists</code> it simply doesn't, as you are referring to the wrong file path</p> <blockquote> <p><strong>public String substring (int start, int end)</strong></p> <p>Since: API Level 1 Returns a string containing a subsequence of characters from this string. The returned string shares this string's backing array.</p> <p>Parameters start the offset of the first character. end the offset one past the last character. Returns a new string containing the characters from start to end - 1</p> </blockquote> <p>You have misused <code>substring</code>. It get the substring from start to end -1. You have -1 yourself, so infact you have actually caused it to -2 from the folder directory.</p> <p>If you remove the extra -1 and decrease start of next substring by 1, it should work.</p> <pre><code>int end = from.toString().lastIndexOf("/") ; String str1 = from.toString().substring(0, end); String str2 = from.toString().substring(end+1, from.length()); </code></pre> <p><strong>EDIT:</strong></p> <p>An improved way would be to make use of the <code>File</code> methods</p> <pre><code>File source = new File(from); //creates file from full path name String fileName = source.getName(); // get file name File destination= new File(to, fileName ); // create destination file with name and dir. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload