file.getName() on a File object created in Android from a file path generated in Java produces strange results -


i have huge problem program either didn't have before or didn't notice. have submit work in 3.5 hours can me sees before then.

i have java program user select files , paths of files passed android application. within android application, create new file object using path, , later on call fileobject.getname().

this produces different results depending on if java program run in ubuntu or windows. if run ubuntu android app succesfully extracts file name, if run windows android app extracts full path.

i had path sent android canonical path, , i've since changed absolute path because wasn't sure if causing issue. hasn't resolved problem. issue result of creating file object within android using windows path? thought wouldn't matter guess wrong.

if me within next couple of hours might save degree, because important project , have had submit report not mention issue have encountered, can't explain more have fix it.

for clarification, if select file in windows has path c:\users\username\pictures\picture.jpeg

and pass android, getname() method return's exact path method

whereas if ubuntu path /home/username/pictures/picture.jpeg , pass android getname() returns picture.jpeg need.

many thanks.

if want filename, manually extract last component of path string. -

file f; int index = f.getname().lastindexof('\'); string filename = f.getname().substring(index+1); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -