Java Unix Path unixToUserPathName(String unixPathName)

Here you can find the source of unixToUserPathName(String unixPathName)

Description

unix To User Path Name

License

Open Source License

Declaration

public static String unixToUserPathName(String unixPathName) 

Method Source Code

//package com.java2s;
/*/*  ww  w. j a  v  a  2 s  . co m*/
 * Copyright (C) 2014, United States Government, as represented by the
 * Administrator of the National Aeronautics and Space Administration.
 * All rights reserved.
 *
 * The Java Pathfinder core (jpf-core) platform is licensed under the
 * Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 *        http://www.apache.org/licenses/LICENSE-2.0. 
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */

public class Main {
    public static String unixToUserPathName(String unixPathName) {
        if (unixPathName.startsWith("~/")) {
            return "${user.home}" + unixPathName.substring(1);
        } else {
            String userHome = System.getProperty("user.home");
            int len = userHome.length();
            if (unixPathName.startsWith(userHome)
                    && unixPathName.charAt(len) == '/') {
                return "${user.home}" + unixPathName.substring(len);
            } else {
                return unixPathName;
            }
        }
    }
}

Related

  1. toUNIXfilePath(String fileName)
  2. unixizeWindowsAbsolutePath(final String pathToCheck)
  3. unixPath(String sText)
  4. unixPathStr(String anyPath)
  5. unixPathToWindows(String strPath)