String imgpath =" /mnt/sdcard/joke.png" ;;
输出:"的/ mnt / SD卡
答案 0 :(得分:1)
有几种选择。
根据https://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/
$(document).ready(function(){
//Read CSV
$.ajax({
type: "GET",
url: "airport.txt",
dataType: "text"
})
.done(function(data){
//process CSV Data
processCsv(data);
})
.fail(function(){
alert("Error: Failed to load data");
});
});
function processCsv(data){
//Read CSV Data into multidimensional Array
var array = $.csv.toArrays(data);
//Put headers in own array
var headers = array.splice(0,1);
//Make each header its own value
var headerString = headers.toString();
headers = headerString.split(',');
//separate all array values
var arrayString = array.toString();
array = arrayString.split(',');
return { header:headers, values:array};
}
或使用String imgpath ="/mnt/sdcard/joke.png";
String path = imgpath . substring(0, imgpath.lastIndexOf(File.separator));
java.io.File
我更喜欢后者,但这取决于你。