java - File path problems in windows environment -


i have following line of code:

"%s/ramp_adapter/user_%d/ramp_file_receipt/%d".format(new java.io.file(".").getabsolutepath().replace("/.",""), endpointid, fileid) 

if print line in window wrong file path:

e:\git\project\codeadapters\rampadapter\./ramp_adapter/user_1001/ramp_file_receipt/3 

in unix, file path coming correct.

i know need make compatible windows , tried using filenameutils didn't resolved problem.

the path should correct in environments.

replace

"%s/ramp_adapter/user_%d/ramp_file_receipt/%d" 

with

"%s" + file.separatorchar + "ramp_adapter" + file.separatorchar + "user_%d" + file.separatorchar + "ramp_file_receipt" + file.separatorchar + "%d" 

replace

getabsolutepath().replace("/.","") 

with

getabsolutepath().replace(file.separator + ".", "") 

Comments

Popular posts from this blog

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -