Get File Information

Hi!
I wonder if you know any way to get the extension of a file, and his creation date too. I know File class exists, but this one does not contain these methods.
Do you know any way to get it both?
Thank you very much,
imladris

here.. I'm feeling generous...
import java.io.File;
public class Test
   public static void main(String[] args)
       // returns "ext"
       System.out.println(getExtension(new File("test.ext")));
       // returns null
       System.out.println(getExtension(new File("noextension")));
   public static String getExtension(File file) {
       String name = file.getName();
       int lastDot = name.lastIndexOf('.');
       if (lastDot == -1) {
           // there is no extension
           return null;
       return name.substring(lastDot+1);
}And I don't think you can get the creation date, because as stated, not all file systems support that.

Similar Messages

  • Get File Information using the Document ID in Javascript

    I store in a custom list the Document Id of a linked document. I need to retrieve some metadata - at least the filename - of that document. I have tried using the Search REST API specifying something like "DocID:INGX1-2-26" in my search query,
    but nothing is returned, nothing found.
    Is there any other way to get the file info when all I have is the Document ID? In the managed code, I could use the Microsoft.Office.DocumentManagement.dll which provides a way to get the file info using the DocId, but this is not available in Javascript.
    Any ideas?
    thanks.

    Hi,
    As a workaround, we can create a custom web service with the Microsoft.Office.DocumentManagement.dll, then you can call the web service using JavaScript.
    Here are some links about Building and Consuming Custom WCF Services hosted in SharePoint for your reference:
    http://nikpatel.net/2012/02/29/step-by-step-building-custom-wcf-services-hosted-in-sharepoint-part-i/
    http://www.c-sharpcorner.com/uploadfile/sridhar_subra/consuming-wcf-asmx-rest-service-using-jquery/
    http://leonidius2010.wordpress.com/2011/05/06/custom-web-service-for-sharepoint-an-easy-way/
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they
    help and unmark them if they provide no help. If you have feedback for TechNet
    Subscriber Support, contact [email protected]
    Patrick Liang
    TechNet Community Support

  • When i try to run my jsp i get "File Download Security Warning"

    Hi,
    I have created a jsp file which is called UpdateEmpDetails1.jsp
    This jsp file picks up the employee id of the employee and transfers it to the backend servlet called UpdateEmpDetails1.java. The backend servlet looks up the table stored in the database and pulls up all the information stored corresponding to the employee id.Then the servlet stores the information in a session object and forwards it to the UpdateEmpDetails2.jsp
    I display the information which has been forwarded by the servlet in the HTML fields of UpdateEmpDetails2.jsp.
    Here the manager can also update the information. When he clicks on submit, the second serlvet UpdateEmpDetails2.java which is linked to UpdateEmpDetails2.jsp picks up the updated information and updates the database. The servlet also displays the message "Your information has been updated". But here is the real problem
    The session variables are being transferred perfectly to the jsp file UpdateEmpDetails2.jsp.
    But when i make any changes to this file and click on submit I get File Download Security Warning. It Says:
    File Download Security Warning
    Do you want to save this file
    Name UpdateEmpDetails2
    Type UnknownFileType
    From LocalHost
    Then I get another file which says
    FileDownload
    Getting FIle Information
    UpdateEmpDetails2 from localhost
    Estimated time left
    Download to:
    Transfer rate:
    Close this dialog box when download is complete
    I am just simply not able to update the employee information in the database due to this message.

    this is what i am trying to do:
    my UpdateEmpDetails1.jsp is as follows:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional //EN">
    <html>
    <head>
    <title>UpdateEmpDetails1.jsp</title>
    <link REL=STYLESHEET
    HREF="JSP-Styles.css"
    TYPE="text/css">
    </head>
    <body BGCOLOR="lightyellow" text="black">
    <h2 align="left"><font color="black">Update Employee Details Page</font></h2>
    <form action="UpdateEmpDetails2" Method="Get">
    <h2 align="left">Please enter the Employee ID of the employee whose details you want to edit</h2>
    <table width=50% align="center">
    <tr><td>Employee ID : </td>
         <td><INPUT TYPE="TEXT" name="employeeid"><br></td></tr>
    <tr><td><center><INPUT TYPE="SUBMIT" VALUE="SUBMIT"></center></td></tr>
    <tr><td><center><INPUT TYPE="RESET" VALUE="RESET"></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    my update EmpDetails1.java is as follows:
    package com.update;
    import com.database.*;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    public class UpdateEmpDetails1 extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              HttpSession session = request.getSession();
              String X = request.getParameter("employeeid");
              System.out.println("Employee ID:" + X);
              //Establishing the jdbc connection
              try
                   Database db = new Database();
                   Connection con = db.useConnection();
                   String query = "Select * from employees where employeeid=?";
                   PreparedStatement stat = con.prepareStatement(query);
                   System.out.println(stat);
                   stat.setString(1,X);
                   ResultSet rs = stat.executeQuery();
                   while(rs.next())
                        String A = rs.getString("employeeid");
                        String B = rs.getString("firstname");
                        String C = rs.getString("lastname");
                        String D = rs.getString("gender");
                        String E = rs.getString("dateofbirth");
                        String F = rs.getString("address");
                        String G = rs.getString("postalcode");
                        String H = rs.getString("phone");
                        String I = rs.getString("mobile");
                        String J = rs.getString("designation");
                        String K = rs.getString("joindate");
                        String L = rs.getString("leavedate");
                        String M = rs.getString("email");
                        String N = rs.getString("qualification");
                        String O = rs.getString("empstatus");
                             System.out.println("comparison successful");
                             session.setAttribute("employeeid",A);
                             session.setAttribute("firstname", B);
                             session.setAttribute("lastname", C);
                             session.setAttribute("gender", D);
                             session.setAttribute("dateofbirth", E);
                             session.setAttribute("address", F);
                             session.setAttribute("postalcode", G);
                             session.setAttribute("phone", H);
                             session.setAttribute("mobile", I);
                             session.setAttribute("designation", J);
                             session.setAttribute("joindate", K);
                             session.setAttribute("leavedate", L);
                             session.setAttribute("email", M);
                             session.setAttribute("qualification", N);
                             session.setAttribute("empstatus", O);
                             String url="/UpdateEmpDetails2.jsp";
                             RequestDispatcher dis = request.getRequestDispatcher("/UpdateEmpDetails2.jsp");
                             System.out.println("Dispatching" + dis);
                             dis.forward(request, response);
              catch(Exception e)
                   System.out.println(e);
    my UpdateEmpDetails2.jsp is as follows:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>UpdateEmpDetails2.jsp</title>
    <link REL=STYLESHEET
    HREF="JSP-Styles.css"
    TYPE="text/css">
    </head>
    <body BGCOLOR="lightblue" text="black">
    <h1 align="center"><font color="black">Update Employee Details Page</font></h1>
    <form action="UpdateEmpDetails2" Method="Get">
    <table width=50% align="center">
    <tr><td>EMPLOYEE ID:</td>
         <td><INPUT TYPE = "HIDDEN" name="employeeid" value=<%=session.getAttribute("employeeid")%> ></td></tr>
    <tr><td>FIRST NAME :</td>
         <td><INPUT TYPE = "TEXT" name="firstname" value=<%=session.getAttribute("firstname")%> ></td></tr>
    <tr><td>LAST NAME :</td>
         <td><INPUT TYPE = "TEXT" name="lastname" value=<%=session.getAttribute("lastname")%> ><br></td></tr>
    <tr><td>GENDER :</td>
         <td><INPUT TYPE = "TEXT" name="gender" value=<%=session.getAttribute("gender")%> ><br></td></tr>
    <tr><td>DATE OF BIRTH (IN MM/DD/YYYY FORMAT) :</td>
         <td><INPUT TYPE = "TEXT" name="dateofbirth" value=<%=session.getAttribute("dateofbirth")%> ><br></td><tr>
    <tr><td>ADDRESS :</td>
         <td><INPUT TYPE = "TEXT" name="address" value=<%=session.getAttribute("address")%> ><br></td></tr>
    <tr><td>POSTALCODE:</td>
         <td><INPUT TYPE = "TEXT" name="postalcode" value=<%=session.getAttribute("postalcode")%>><br></td></tr>
    <tr><td>PHONE:</td>
         <td><INPUT TYPE = "TEXT" name="phone" value=<%=session.getAttribute("phone")%> ><br></td></tr>
    <tr><td>MOBILE:</td>
         <td><INPUT TYPE = "TEXT" name="mobile" value=<%=session.getAttribute("mobile")%> ><br></td></tr>
    <tr><td>DESIGNATION : </td>
    <td><INPUT TYPE="TEXT" name="designation" value=<%=session.getAttribute("designation")%> > <br></td></tr>
    <tr><td>JOIN DATE:</td>
         <td><INPUT TYPE = "TEXT" name="joindate" value=<%=session.getAttribute("joindate")%> ><br></td></tr>
    <tr><td>LEAVE DATE:</td>
         <td><INPUT TYPE = "TEXT" name="leavedate" value=<%=session.getAttribute("leavedate")%> > <br></td></tr>
    <tr><td>EMPLOYEE EMAIL:</td>
         <td><INPUT TYPE = "TEXT" name="email" value=<%=session.getAttribute("email")%> ><br></td></tr>
    <tr><td>EMPLOYEE QUALIFICATION:</td>
         <td><INPUT TYPE = "TEXT" name="qualification" value=<%=session.getAttribute("qualification")%> > <br></td></tr>
    <tr><td>EMPLOYEE STATUS:</td>
         <td><INPUT TYPE = "TEXT" name="empstatus" value=<%=session.getAttribute("empstatus")%> > <br></td></tr>
    <tr><td><center><INPUT TYPE="SUBMIT" VALUE="SUBMIT"></center></td></tr>
    <tr><td><center><INPUT TYPE="RESET" VALUE="RESET"></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    my UpdateEmpDetails2.java is as follows:
    package com.update;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import com.database.*;
    public class UpdateEmpDetails2 extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              PrintWriter out = response.getWriter();
              response.setContentType("texthtml");
              String A = request.getParameter("employeeid");
              out.println(A);
              String B = request.getParameter("firstname");
              out.println(B);
              String C = request.getParameter("lastname");
              out.println(C);
              String D = request.getParameter("gender");
              out.println(D);
              String E = request.getParameter("dateofbirth");
              out.println(E);
              String F = request.getParameter("address");
              out.println(F);
              String G = request.getParameter("postalcode");
              out.println(G);
              String H = request.getParameter("phone");
              out.println(H);
              String I = request.getParameter("mobile");
              out.println(I);
              String J = request.getParameter("designation");
              out.println(J);
              String K = request.getParameter("joindate");
              out.println(K);
              String L = request.getParameter("leavedate");
              out.println(L);
              String M = request.getParameter("email");
              out.println(M);
              String N = request.getParameter("qualification");
              out.println(N);
              String O = request.getParameter("empstatus");
              out.println(O);
              try
              Database db = new Database();
              Connection con = db.useConnection();
              String query= "update employees set employeeid=?,firstname=?,lastname=?,gender=?,dateofbirth=?,address=?,postalcode=?,phone=?,mobile=?,designation=?,joindate=?,leavedate=?,email=?,qualification=? where employeeid=?";
              PreparedStatement stat = con.prepareStatement(query);
              stat.setString(1, B);
              stat.setString(2, C);
              stat.setString(3, D);
              stat.setString(4, E);
              stat.setString(5, F);
              stat.setString(6, G);
              stat.setString(7, H);
              stat.setString(8, I);
              stat.setString(9, J);
              stat.setString(10, K);
              stat.setString(11, L);
              stat.setString(12, M);
              stat.setString(13, N);
              stat.setString(14, O);
              stat.setString(15, A);
              System.out.println(stat);
              int i = stat.executeUpdate();
              if (i!= 0)
              System.out.println("The record has been updated");
              else
                   System.out.println("Sorry ! failure");
              ResultSet rs = stat.executeQuery("select * from employees");
              System.out.println(rs);
              while(rs.next())
                   out.print("<table border='1'>");
                   out.println(rs.getString(1) + "<br>");
                   out.println(rs.getString(2) + "<br>");
                   out.println(rs.getString(3) + "<br>");
                   out.println(rs.getString(4) + "<br>");
                   out.println(rs.getString(5) + "<br>");
                   out.println(rs.getString(6) + "<br>");
                   out.println(rs.getString(7) + "<br>");
                   out.println(rs.getString(8) + "<br>");
                   out.println(rs.getString(9) + "<br>");
                   out.println(rs.getString(10) + "<br>");
                   out.println(rs.getString(11) + "<br>");
                   out.println(rs.getString(12) + "<br>");
                   out.println(rs.getString(13) + "<br>");
                   out.println(rs.getString(14) + "<br>");
                   out.println(rs.getString(15) + "<br>");
                   out.print("<br>");
              catch (Exception e)
                   System.out.println(e);
                   e.printStackTrace();
    Now as soon as i click on the submit button of the first jsp i get "File Download security warning message"
    I am new to jsp and i am not able to troubleshoot this

  • An unknown excel file has appeared on my desktop. It cannot be deleted and I cannot get any information about it. Is this malware?  How can I get rid of it?

    An unknown excel file has appeared on my desktop. It cannot be deleted and I cannot get any information about it.
    Is this malware?  How can I get rid of it?

    Hello Jeff,
    Thanks very much for your reply.  I looked over the article you mentioned, but I have tried all of these methods, but only get the response "The item “29394D00” can’t be moved to the Trash because it can’t be deleted."  Similarly, I cannot Get Info on the file.  This is why I'm so concerned, it just appeared on my desktop, but I cannot touch it, or open it or delete it...
    If you have any more tricks up your sleeve, I'd love to hear about them...
    Derek

  • How i get some informations about audio file?

    Hi to all,
    i would like to know how i get some informations about audio file, such as its artist, bitrate, file type, duration, ecc...
    Any help me?

    Ok, but which are the docs of audio format?Again, what does that have to do with Java?
    Where i can found these documents?Again, what does that have to do with Java?
    Thank you...For nothing.
    db

  • How can you get File/Folder information?

    Hello,
    I'm a Windows XP/Vista convert. One thing I liked about XP and Vista is how you could simply point to a file, hover the pointer over it and it would tell you information about it. Also, in the status bar it would tell you the total amount of space occupied by all the files in a folder.
    Is there a way to get this same functionality in OSX? I haven't upgraded to Leopard just yet, but I wonder if it has this functionality built into it. Very simple features, but can 10.4.10 or 10.5 do either one? Or is there a simple utility that will give this functionality to the Finder?
    Also, what's the BEST file manager for OSX out there? I use PowerDesk in XP quite a bit, is there something similar out there for the Mac?
    Thanks,
    Jeff

    Thanks, but I meant to add, is there some way to get this information other than the way you've outlined? I like how Windows handles it, either by displaying it in the status bar or showing a bubble/popup by just hovering the mouse over the icon. Please tell me that Leopard will do this. I mean, that seems like a VERY basic feature that, well, just makes sense to me. It shouldn't be anymore difficult than that.
    Is this addressed in another way in MacOSX?
    Thanks,
    Jeff

  • How to get the files' information?

    I' d want to get the files' information in the action, such
    as the .avi or .flv information about their duration and the
    default image,
    please help, thanks.

    Hi,
    You could use Oracle workflow builder to do thar....
    Regards,
    Luiz

  • Getting version information on  jar files

    I want to install the Portal Tools Application from PDK. There are some files to be copied to subdirectories of ORA_HOME. Some of the files like jewt4.jar already exists and according to the install guide you have to leave existing files unchanged when they are newer then the PDK files. To get version information you can ,according to the guide, check if the "Jar file contains a file with a version number , e.g., ...." How do I check this? Why is it not enough to check the last modified date of the files in explorer?

    It's not enough to check the last modified date because this can easily be changed, e.g. by using 'touch'.
    To check for these version numbers, in a unix environment do:
    jar -tvf | grep version
    In a windows env, open the jar file up in WinZip and scroll through the members, looking for a likely candidate.
    Regards,
    Gareth
    (PDK team)

  • To get the saved files information in illustrator?

    How to get the saved file information (EPS Options) in illustrator cs3 files like Version, Format, Transparency,Fonts,Include Document Thumbnails etc. through programmatically. Please advice me.

    Please help me, I have precious pictures that I can't download.

  • Checking for file conflicts: could not get filesystem information

    When I try to install a new package with pacman 4 I got the following warning just after pacman has done "checking for file conflicts":
    warning: could not get filesystem information for /var/lib/ntp/etc/resolv.conf (deleted): No such file or directory
    After the warning message is printed, the installation continues normally.  This warning message has never shown up before.
    I have ntpd running in a chroot as a non-root user (instructions).
    I am wondering if anyone else gets the same warning message and if this 'problem' can be solved.
    I forgot to say: the file is still there according to ls and is not empty, but the contents differs form the /etc/resolv.conf-file.
    tim@tim-notebook:~$ cat /var/lib/ntp/etc/resolv.conf && echo && cat /etc/resolv.conf
    # Generated by NetworkManager
    # Generated by NetworkManager
    nameserver 192.168.1.1
    Last edited by timothy (2012-01-19 00:15:51)

    I'm not sure how to do that or I do not know exactly what you mean.
    tim@tim-notebook:~$ pkgfile -gs "*etc/resolv.conf"
    core/filesystem
    extra/archboot
    But you probably already knew that.
    Running pacman with the --debug option did not gave me any more clues.  All I know now, is that this message is printed when the moundpoints are examined:
    stderr 'pacman -Syu--debug' output wrote:(...)
    debug: checking possible conflict: /var/lib/
    debug: file is a directory, not a conflict
    debug: checking available disk space
    warning: could not get filesystem information for /var/lib/ntp/etc/resolv.conf (deleted): No such file or directory
    debug: mountpoint: /var/lib/ntp/proc
    debug: mountpoint: /var/lib/ntp/lib
    debug: mountpoint: /var/lib/ntp/etc/services
    debug: mountpoint: /tmp

  • When viewing a photo in full screen, how do I get the file information and data along the footer.  How do i get that to go off?  Preferences.....???

    Love full screen view, but my file information and data are showing along the footer.  How do I change me settings so this doesn't show?
    Thanks!!!!

    Anne, didn't the answers Frank and I gave in the other tread work? See:
    Re: How do I turn of the focus points in Aperture when viewing a photo in a non-thumbnail view?  Thanks!
    Or did you want to know something differently?

  • How to get extract audio file information ?

    Hi guys, i m working on project which processes audio and video files and give their details.
    I want to knw how can i extract audio or video file information like author, duration , bit rate, etc frm audio or video file. how can i achieve this ??
    Plz help me

    [http://www.lmgtfy.com/?q=Java+meta-data+video]

  • How to get file from FTP Server using File Control

    Hi,
    Any one did getting file from FTP Server?
    Please let me know any one help me.
    I would need to get file from FTP Server.
    Thanks,
    Madhu

    Yes I have done that. But In FTP Server I cannt read file, because no previliges. Only I need to copy file from FTP Server to local server then only I can read that file.
    I tried all options using FileConrol(getFiles(),read()).
    getFiles() - It wont copy the file, it give information about file.
    read() - I dont have previliges to read the file.
    Please tell me any other procedure would be there for getting file from FTPServer.
    Thanks,
    Madhu

  • I am new to Mac Pro but am purchasing one online.  can anyone tell me how to get the information from my Toshiba onto the Mac.  there are no stores in the state I live in.  Do I need to find a location and will they do a transfer from my I Tunes etc?

    I am new to Mac Pro and am purchasing one online  tonight.  Can anyone tell me how to get my information - Itunes, photos, and videos transferred onto the Mac from my Toshiba.  the state I live in doesn't have an Apple store but I could take it to Minneapolis when I go.  Any ideas where to begin?

    You might profit from a visit to a Minneapolis Apple store. With a brand new Mac, I think they will be most helpful - not just with transferring files, but with other advice as well. And I strongly recommend you invest in a back up drive. The Apple folk can help with that as well.

  • How to get timesheet information in a javascript (Project Server 2013)

    Hi all,
    In Project Server 2013, I'm trying to customize the Timesheet ribbon. This far, I've been able to add a new button and tie an event to it. All is working well. This is all done using elements.xml and a javascripts.
    Now the problem is that I want to get some informations about the timesheet (the Guid for example) and, for now, I've got no success. I know that there is an object called PS.TimeSheet, but when I try to use some PS.TimeSheet's methods I get an error.
    Note that i'm in the page http://servername/pwa/timesheet.aspx (there is not Guid in the address) and all the treatments should be done in the javascript (no call to another aspx page)
    Thanks !

    Finally, I've found the solution.
    My goal was to add a button in the timesheet ribbon to launch a special report showing some data about the timesheet. The report has the timesheet Guid as parameter.
    To customize the Sharepoint ribbon, you have to do it via an xml file and a javascript (a lot of explanation is available in the internet that explains how to do it). So I had to call a function in the javascript to launch the report (which is a SSRS report).
    When you are in a javascript you have access to many global variables. When the timesheet.aspx is displayed, there is a global variable called "timesheetComponent".
    Using this variable we can call the method :
    timesheetComponent.m_consumedApi.get_Impl()
    to get an implementation of the current timesheet. This implementation has an attibute that has a lot of nice stuff about the current user and the current time sheet. This attribute is 
    _headerInfo
    _headerInfo is a structure that includes tsUid which contains the timesheet Guid I was looking for.
    Finally, the function attached to the button goes like this :
    function _LaunchReport() {
    var tsUId;
    var rptPath;
    var tsImpl = timesheetComponent.m_consumedApi.get_Impl();
    try
    if (CONST_REPORT_PATH == null || CONST_REPORT_PATH == "" ) {
    alert("Constant CONST_REPORT_PATH is not defined")
    else {
    tsUId = tsImpl._headerInfo.tsUid;
    rptPath = CONST_REPORT_PATH + 'TimesheetDetails&rs:Command=Render&rc:Parameters=false&TimesheetUID=' + tsUId;
    window.open(rptPath);
    catch (Err) {
    alert(Err)
    CONST_REPORT_PATH is the path to SSRS defined elsewhere
    I hope this will help some other poeple !

Maybe you are looking for

  • E-mail Alert Notification Action doesn't work

    Don't receive Alert notifications on email. Attributes-> Actions-> Critical Action send to email. At occurrence Critical Alert of the notification are not sent on email. If a host or the agent are not accessible, the notification is sent on my email.

  • Central Person already exists

    Hi Experts, I am Using ECS,SRM4.0. I have one problem when I am assigning one user thru <Users_Gen> from already SU01 list and all at the end I am getting one error msg like Central Person for this user already exists with E BBPU_MESSAGES 042 & becau

  • Time Capsule Access Privileges

    I'm getting the message "you do not have the correct read, write and append privileges, please contact your system administrator or log in as a different user." I had to re-establish my Mac Book Pro using a time machine backup and started receiving t

  • IPod Touch 4.2 and Airport Extreme

    I have just updated my iPod Touch 64GB (Model MC011LL) with version 4.2.1 (8C148) and read about the Airprint application, which could be pretty useful. Strangely, although I have a "wireless printer", a Canon all-in-one MX860, it is connected (corre

  • My Encore crashes CS5 and CS6

    Two week ago my Encore CS5 started acting weird. When I try and create a new project or open and existing project it crashes. I uninstalled and reinstalled and the issue continued. I just upgraded to CC and downloaded PP6 to get Encore. When I loaded