Results 1 to 6 of 6

Thread: How to Manage Metadata in Java?

  1. #1
    Join Date
    Jul 2006
    Posts
    339

    How to Manage Metadata in Java?

    Hi friends,
    I am doing the Core Java from some time. I know very less about the Metadata. And now I want to manage the metadata. I have tried to do some things but I am not getting succeeded. I think since, I don't know much about the metadata that's why I am not able to do the things. Can anyone explain me what is metadata. And also please tell me how to Manage Metadata in Java? Hoping some help from you guys.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    349

    Re: How to Manage Metadata in Java?

    Before managing the metadata, I think that you should know about the metadata. Knowing the metadata is very important from coding point of view. Because nowadays, the latest trends in programming, especially in Java programming, is the use of metadata. You can use the metadata for creating documentation, tracking down dependencies in code, and with the help of metadata, you can also perform rudimentary compile-time checking. Metadata's benefits fall into three categories: documentation, compiler checking, and code analysis. In simple words, you can say that metadata is data about data.

  3. #3
    Join Date
    Mar 2008
    Posts
    672

    Re: How to Manage Metadata in Java?

    With a file system, the data is contained in its files and directories, and the metadata tracks information. The package that provides an API to manage the file system's metadata is the java.nio.file.attribute package. You can store the metadata internally in the same file as the data or you can also store the metadata externally in a separate file. Metadata that is embedded with content is called embedded metadata. The core Java language came closest to a metadata facility with the Javadoc methodology. You use a special set of tags to mark up your code and then execute the javadoc command to turn the tags into a formatted HTML page.

  4. #4
    Join Date
    Aug 2006
    Posts
    235

    Re: How to Manage Metadata in Java?

    I have given you an example in which readFileAttributes method returns an instance of FileAttributes, which provides a number of methods for retrieving the attribute information. The following code snippet reads and prints the basic file attributes for a given file :
    Code:
    Path file = ...;
    FileAttributes fa = Attributes.readFileAttributes(file);
    
    if (fa.creationTime() != null) {
        System.out.println("creationTime: " + fa.creationTime());
    }
    if (fa.lastAccessTime() != null) {
        System.out.println("lastAccessTime: " + fa.lastAccessTime());
    }
    if (fa.lastModifiedTime() != null) {
        System.out.println("lastModifiedTime: " + fa.lastModifiedTime());
    }
    
    System.out.println("isDirectory: " + fa.isDirectory());
    System.out.println("isOther: " + fa.isOther());
    System.out.println("isRegularFile: " + fa.isRegularFile());
    System.out.println("isSymbolicLink: " + fa.isSymbolicLink());
    System.out.println("size: " + fa.size());
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  5. #5
    Join Date
    Aug 2006
    Posts
    227

    Re: How to Manage Metadata in Java?

    If you want to determine whether a file is a regular file that can be executed (and not a directory), the example provided by 'MELTRONICS' is extended to check the file type by using the basic file attributes. The following is the sample of coding :
    Code:
    import static java.nio.file.AccessMode.*;
    
    Path file = .....give your path file here....;
    boolean error=false;
    
    try {
        file.checkAccess(READ, EXECUTE);
        if (!Attributes.readFileAttributes(file).isRegularFile()) {
            error = true;
        }
    } catch (IOException x) {
        error = true;
    }
    if (error) {
        return;
    }
    Last edited by Solitario; 19-02-2010 at 03:40 AM.
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  6. #6
    Join Date
    Nov 2008
    Posts
    996

    Re: How to Manage Metadata in Java?

    In many scenarios you need to check the space available on file. For that you can use the readFileStoreSpaceAttributes(FileStore) method to learn how much space is available on a file store. The following coding may be useful to you :
    Code:
    Path file = ...;
    FileStore fs = file.getFileStore();
    FileStoreSpaceAttributes fa = Attributes.readFileStoreSpaceAttributes(store);
    
    long total = fa.totalSpace() / 1024;
    long used = (fa.totalSpace() - fa.unallocatedSpace()) / 1024;
    long avail = fa.usableSpace() / 1024;
    
    System.out.println("fs: " + store);
    System.out.println("total: " + attr.totalSpace() / 1024);
    System.out.println("used:  " + (attr.totalSpace() - attr.unallocatedSpace()) / 1024);
    System.out.println("avail: " + fa.usableSpace() / 1024);

Similar Threads

  1. Java code to manage book accounts
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 26-02-2010, 04:57 AM
  2. Manage time in java
    By Vodka in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 12:55 AM
  3. What is file metadata
    By chetu in forum Operating Systems
    Replies: 3
    Last Post: 09-09-2009, 09:57 AM
  4. How to read AAC metadata
    By neonxgenesis in forum Windows Software
    Replies: 3
    Last Post: 19-08-2009, 09:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,524,068.11348 seconds with 17 queries