Replace Backslash by Normal Bar in a string with Processing

Hello guys,

I'm trying to load some images using the selectFolder function, the problem is that it looks like in Processing it needs to be with the normal bar, rather than the inverted one.

For example, the folder I chose looks like this: C:\Images and it would look like this: C:/Images

I tried to use the replaceAll function to override in the String, but it is not working.

Below is the example.

private String pathImg;

void setup() {
  selectFolder("Select a folder to process:", "folderSelected");  
}

void folderSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    pathImg = selection.getAbsolutePath();
    //String newPath = pathImg.replaceAll("\", "/");
    //pathImg = newPath;
    println("Path: " + pathImg);
  }
}

Thanks for listening

Answers

Sign In or Register to comment.