All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bbn.bue.common.converters.StringToOSFile Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
package com.bbn.bue.common.converters;

import com.bbn.bue.common.os.OSDetector;

import java.io.File;

import static com.google.common.base.Preconditions.checkNotNull;

public class StringToOSFile implements StringConverter {

  public StringToOSFile() {
  }

  public Class getValueClass() {
    return File.class;
  }

  @Override
  public File decode(final String s) {
    String path = s;
    if (OSDetector.isWindows()) {
      path = path.replace("/nfs/", "\\\\").replace("/", "\\");
    } else {
      path = path.replace("\\\\", "/nfs/").replace("\\", "/");
    }
    return new File(checkNotNull(path));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy