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


Java FTPFile.setTimestamp方法代碼示例

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


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

示例1: parseMemberList

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
 * Parse entries within a partitioned dataset.
 *
 * Format of a memberlist within a PDS: 1 2 3 4 5 6 7 8 9 Name VV.MM Created
 * Changed Size Init Mod Id TBSHELF 01.03 2002/09/12 2002/10/11 09:37 11 11
 * 0 KIL001 TBTOOL 01.12 2002/09/12 2004/11/26 19:54 51 28 0 KIL001
 *
 * ------------------------------------------- [1] Name [2] VV.MM: Version .
 * modification [3] Created: yyyy / MM / dd [4,5] Changed: yyyy / MM / dd
 * HH:mm [6] Size: number of lines [7] Init: number of lines when first
 * created [8] Mod: number of modified lines a last save [9] Id: User id for
 * last update
 *
 *
 * @param file
 *            will be updated with Name, Type and Timestamp if parsed.
 * @param entry zosDirectoryEntry
 * @return true: entry was parsed, false: entry was not parsed.
 */
private boolean parseMemberList(FTPFile file, String entry) {
    if (matches(entry)) {
        file.setRawListing(entry);
        String name = group(1);
        String datestr = group(2) + " " + group(3);
        file.setName(name);
        file.setType(FTPFile.FILE_TYPE);
        try {
            file.setTimestamp(super.parseTimestamp(datestr));
        } catch (ParseException e) {
            e.printStackTrace();
            // just ignore parsing errors.
            // TODO check this is ok
            return false; // this is a parsing failure too.
        }
        return true;
    }

    return false;
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:40,代碼來源:MVSFTPEntryParser.java

示例2: parseFTPEntry

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
     * Parses a line of an OS2 FTP 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>
     * @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 size = group(1);
            String attrib = group(2);
            String dirString = group(3);
            String datestr = group(4)+" "+group(5);
            String name = group(6);
            try
            {
                f.setTimestamp(super.parseTimestamp(datestr));
            }
            catch (ParseException e)
            {
                // intentionally do nothing
            }


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


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

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

            return (f);
        }
        return null;

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

示例3: 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

示例4: parseFTPEntry

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
     * Parses a line of an NT FTP 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>
     * @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();
        f.setRawListing(entry);

        if (matches(entry))
        {
            String datestr = group(1)+" "+group(2);
            String dirString = group(3);
            String size = group(4);
            String name = group(5);
            try
            {
                f.setTimestamp(super.parseTimestamp(datestr));
            }
            catch (ParseException e)
            {
                // parsing fails, try the other date format
                try
                {
                    f.setTimestamp(timestampParser.parseTimestamp(datestr));
                }
                catch (ParseException e2)
                {
                    // intentionally do nothing
                }
            }

            if (null == name || name.equals(".") || name.equals(".."))
            {
                return (null);
            }
            f.setName(name);


            if ("<DIR>".equals(dirString))
            {
                f.setType(FTPFile.DIRECTORY_TYPE);
                f.setSize(0);
            }
            else
            {
                f.setType(FTPFile.FILE_TYPE);
                if (null != size)
                {
                  f.setSize(Long.parseLong(size));
                }
            }
            return (f);
        }
        return null;
    }
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:64,代碼來源:NTFTPEntryParser.java

示例5: parseFTPEntry

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
 * Parses a line of an OS2 FTP 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>
 * @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 size = group(1);
        String attrib = group(2);
        String dirString = group(3);
        String datestr = group(4)+" "+group(5);
        String name = group(6);
        try
        {
            f.setTimestamp(super.parseTimestamp(datestr));
        }
        catch (ParseException e)
        {
            // intentionally do nothing
        }


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


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

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

        return (f);
    }
    return null;

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

示例6: 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

示例7: parseFTPEntry

import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
 * Parses a line of an NT FTP 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>
 * @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();
    f.setRawListing(entry);

    if (matches(entry))
    {
        String datestr = group(1)+" "+group(2);
        String dirString = group(3);
        String size = group(4);
        String name = group(5);
        try
        {
            f.setTimestamp(super.parseTimestamp(datestr));
        }
        catch (ParseException e)
        {
            // parsing fails, try the other date format
            try
            {
                f.setTimestamp(timestampParser.parseTimestamp(datestr));
            }
            catch (ParseException e2)
            {
                // intentionally do nothing
            }
        }

        if (null == name || name.equals(".") || name.equals(".."))
        {
            return (null);
        }
        f.setName(name);


        if ("<DIR>".equals(dirString))
        {
            f.setType(FTPFile.DIRECTORY_TYPE);
            f.setSize(0);
        }
        else
        {
            f.setType(FTPFile.FILE_TYPE);
            if (null != size)
            {
              f.setSize(Long.parseLong(size));
            }
        }
        return (f);
    }
    return null;
}
 
開發者ID:kmarius,項目名稱:xdman,代碼行數:63,代碼來源:NTFTPEntryParser.java


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