i have some folders/files in Recent items of windows.what i want to do is i want to know real path of all the files/folders of .lnk shortcuts present in Recent Items.I want result like this. Local path : C:\Program Files (x86)\Windows Live\Mail\wlmail.exe
My code is given
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sir.aimal;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
*
* @author zeeshan
*/
public class SirAimal
{
public static void main(String[] args) throws IOException
{
String user=System.getProperty("user.name");
String path="C:\\Users\\"+user+"\\AppData\\Roaming\\Microsoft\\Windows\\Recent\\";
File directory = new File(path);
File[] fList = directory.listFiles();
for (int i=0;i<fList.length;i++)
{
String filename=fList[i].getName();
String actualfilename=filename.replace(".lnk", "");
Path p = Paths.get(path+filename);
BasicFileAttributes view= Files.getFileAttributeView(p, BasicFileAttributeView.class).readAttributes();
FileTime fileTime=view.creationTime();
System.out.println(actualfilename+"\t\t"+new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format((fileTime.toMillis())));
}
}
}