fork(21) download
  1. import java.io.File;
  2.  
  3. class Main {
  4. public static void main(String[] args) {
  5. File theFile = new File("/sdcard/images/mr.32.png");
  6. System.out.println("Parent : " + theFile.getParent());
  7. String path = "/sdcard/images/mr.32.png";
  8. String parent = path.replaceAll("^(.*)/.*?$","$1");
  9. System.out.println("Parent : " + parent);
  10. }
  11. }
  12.  
Success #stdin #stdout 0.02s 245632KB
stdin
Standard input is empty
stdout
Parent : /sdcard/images
Parent : /sdcard/images