Java Package Convert To packageToDirectory(String sDestDir, String sPackage)

Here you can find the source of packageToDirectory(String sDestDir, String sPackage)

Description

Return a directory path with the given directory + the given

License

LGPL

Parameter

Parameter Description
sDestDir file system directory ( ie "/tmp/src" )
sPackage package name ( ie "org.demo.vo.bean" )

Return

full path of the class file ( ie "/tmp/src/org/demo/vo/bean" )

Declaration

public static String packageToDirectory(String sDestDir, String sPackage) 

Method Source Code

//package com.java2s;
/**/*from w  ww .  jav  a 2  s .c  om*/
 *  Copyright (C) 2008-2013  Telosys project org. ( http://www.telosys.org/ )
 *
 *  Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3.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.gnu.org/licenses/lgpl.html
 *
 *  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 {
    /**
     * Return a directory path with the given directory + the given 
     * @param sDestDir file system directory ( ie "/tmp/src" )
     * @param sPackage package name ( ie "org.demo.vo.bean" )
     * @return full path of the class file ( ie "/tmp/src/org/demo/vo/bean" )
     */
    public static String packageToDirectory(String sDestDir, String sPackage) {
        // --- Replace . by / in the path
        String sPackageDir = sPackage.replace('.', '/');
        if (sDestDir.endsWith("/") || sDestDir.endsWith("\\")) {
            return sDestDir + sPackageDir;
        } else {
            return sDestDir + "/" + sPackageDir;
        }
    }
}

Related

  1. packageToDir(String packages)
  2. PackageToInt(char pack)
  3. packageToPath(Class objClass)
  4. packageToPath(final String packageName)
  5. packageToPath(String basePackage)