當前位置: 首頁>>代碼示例>>Java>>正文


Java FTPFile.setUser方法代碼示例

本文整理匯總了Java中org.apache.commons.net.ftp.FTPFile.setUser方法的典型用法代碼示例。如果您正苦於以下問題:Java FTPFile.setUser方法的具體用法?Java FTPFile.setUser怎麽用?Java FTPFile.setUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.net.ftp.FTPFile的用法示例。


在下文中一共展示了FTPFile.setUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseFTPEntry

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
     * Parses a line of an NetwareFTP server file listing and converts it into a
     * usable format in the form of an <code> FTPFile </code> instance.  If the
     * file listing line doesn't describe a file, <code> null </code> is
     * returned, otherwise a <code> FTPFile </code> instance representing the
     * files in the directory is returned.
     * <p>
     * <p>
     * Netware file permissions are in the following format:  RWCEAFMS, and are explained as follows:
     * <ul>
     * <li><b>S</b> - Supervisor; All rights.
     * <li><b>R</b> - Read; Right to open and read or execute.
     * <li><b>W</b> - Write; Right to open and modify.
     * <li><b>C</b> - Create; Right to create; when assigned to a file, allows a deleted file to be recovered.
     * <li><b>E</b> - Erase; Right to delete.
     * <li><b>M</b> - Modify; Right to rename a file and to change attributes.
     * <li><b>F</b> - File Scan; Right to see directory or file listings.
     * <li><b>A</b> - Access Control; Right to modify trustee assignments and the Inherited Rights Mask.
     * </ul>
     *
     * See <a href="http://www.novell.com/documentation/nfap10/index.html?page=/documentation/nfap10/nfaubook/data/abxraws.html">here</a>
     * for more details
     *
     * @param entry A line of text from the file listing
     * @return An FTPFile instance corresponding to the supplied entry
     */
//    @Override
    public FTPFile parseFTPEntry(String entry) {

        FTPFile f = new FTPFile();
        if (matches(entry)) {
            String dirString = group(1);
            String attrib = group(2);
            String user = group(3);
            String size = group(4);
            String datestr = group(5);
            String name = group(9);

            try {
                f.setTimestamp(super.parseTimestamp(datestr));
            } catch (ParseException e) {
                 // intentionally do nothing
            }

            //is it a DIR or a file
            if (dirString.trim().equals("d")) {
                f.setType(FTPFile.DIRECTORY_TYPE);
            } else // Should be "-"
            {
                f.setType(FTPFile.FILE_TYPE);
            }

            f.setUser(user);

            //set the name
            f.setName(name.trim());

            //set the size
            f.setSize(Long.parseLong(size.trim()));

            // Now set the permissions (or at least a subset thereof - full permissions would probably require
            // subclassing FTPFile and adding extra metainformation there)
            if (attrib.indexOf("R") != -1) {
                f.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION,
                        true);
            }
            if (attrib.indexOf("W") != -1) {
                f.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
                        true);
            }

            return (f);
        }
        return null;

    }
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:77,代碼來源:NetwareFTPEntryParser.java

示例2: parseFTPEntry

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
 * Parses a line of an NetwareFTP server file listing and converts it into a
 * usable format in the form of an <code> FTPFile </code> instance.  If the
 * file listing line doesn't describe a file, <code> null </code> is
 * returned, otherwise a <code> FTPFile </code> instance representing the
 * files in the directory is returned.
 * <p>
 * <p>
 * Netware file permissions are in the following format:  RWCEAFMS, and are explained as follows:
 * <ul>
 * <li><b>S</b> - Supervisor; All rights.
 * <li><b>R</b> - Read; Right to open and read or execute.
 * <li><b>W</b> - Write; Right to open and modify.
 * <li><b>C</b> - Create; Right to create; when assigned to a file, allows a deleted file to be recovered.
 * <li><b>E</b> - Erase; Right to delete.
 * <li><b>M</b> - Modify; Right to rename a file and to change attributes.
 * <li><b>F</b> - File Scan; Right to see directory or file listings.
 * <li><b>A</b> - Access Control; Right to modify trustee assignments and the Inherited Rights Mask.
 * </ul>
 *
 * See <a href="http://www.novell.com/documentation/nfap10/index.html?page=/documentation/nfap10/nfaubook/data/abxraws.html">here</a>
 * for more details
 *
 * @param entry A line of text from the file listing
 * @return An FTPFile instance corresponding to the supplied entry
 */
public FTPFile parseFTPEntry(String entry) {

    FTPFile f = new FTPFile();
    if (matches(entry)) {
        String dirString = group(1);
        String attrib = group(2);
        String user = group(3);
        String size = group(4);
        String datestr = group(5);
        String name = group(9);

        try {
            f.setTimestamp(super.parseTimestamp(datestr));
        } catch (ParseException e) {
             // intentionally do nothing
        }

        //is it a DIR or a file
        if (dirString.trim().equals("d")) {
            f.setType(FTPFile.DIRECTORY_TYPE);
        } else // Should be "-"
        {
            f.setType(FTPFile.FILE_TYPE);
        }

        f.setUser(user);

        //set the name
        f.setName(name.trim());

        //set the size
        f.setSize(Long.parseLong(size.trim()));

        // Now set the permissions (or at least a subset thereof - full permissions would probably require
        // subclassing FTPFile and adding extra metainformation there)
        if (attrib.indexOf("R") != -1) {
            f.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION,
                    true);
        }
        if (attrib.indexOf("W") != -1) {
            f.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
                    true);
        }

        return (f);
    }
    return null;

}
 
開發者ID:kmarius,項目名稱:xdman,代碼行數:76,代碼來源:NetwareFTPEntryParser.java


注:本文中的org.apache.commons.net.ftp.FTPFile.setUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。