本文整理匯總了Java中java.nio.file.attribute.BasicFileAttributes.creationTime方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicFileAttributes.creationTime方法的具體用法?Java BasicFileAttributes.creationTime怎麽用?Java BasicFileAttributes.creationTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.file.attribute.BasicFileAttributes
的用法示例。
在下文中一共展示了BasicFileAttributes.creationTime方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getValueAt
import java.nio.file.attribute.BasicFileAttributes; //導入方法依賴的package包/類
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (columnIndex == 0) {
return templates[rowIndex].getName();
} else if (columnIndex == 1) {
return templates[rowIndex].getVersion();
} else if (columnIndex == 2) {
return templates[rowIndex].getShortDescription();
} else if (columnIndex == 3) {
Path temPath = Paths.get(templates[rowIndex].getFile().getAbsolutePath());
try {
BasicFileAttributes view = Files.getFileAttributeView(temPath, BasicFileAttributeView.class).readAttributes();
FileTime creationTime = view.creationTime();
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
String cTime = df.format(creationTime.toMillis());
return cTime;
} catch (IOException e) {
return "--";
}
} else {
return null;
}
}
示例2: StringKey
import java.nio.file.attribute.BasicFileAttributes; //導入方法依賴的package包/類
StringKey(String title, String tags, BasicFileAttributes fileAttributes, String hashCode, Date importTime, int indexLoc,String filepath,ConcurrentHashMap wordOccurences) {
list[0] = title;
list[1] = tags;
UUID uuid = UUID.randomUUID();
list[2] = (UUID)uuid;
list[3] = fileAttributes;
list[4] = hashCode;
list[5] = fileAttributes.creationTime();
list[6] = importTime;
list[7] = fileAttributes.lastAccessTime();
list[8] = 0;
list[9] = list[8] / (list[7].getTime() - list[6].getTime());
list[11] = 0;
list[12]=filepath;
list[13]=wordOccurences;
list[14]=Integer.toHexString(this.hashCode());
}
示例3: getValueAt
import java.nio.file.attribute.BasicFileAttributes; //導入方法依賴的package包/類
@Override
public Object getValueAt(Object parent, int index) {
if (!(parent instanceof RootNode)) {
if (("template".equals(((TreeTableNode) parent).getType()))) {
switch (index) {
case 0:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getName();
case 1:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getAuthor();
case 2:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getVersion();
case 3:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getDate();
case 4:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getShortDescription();
case 5:
Path temPath = Paths.get(TEMPLATE_FOLDER + ((TemplateData) ((TreeTableNode) parent).getData()[0]).getFileName());
try {
BasicFileAttributes view = Files.getFileAttributeView(temPath,BasicFileAttributeView.class).readAttributes();
FileTime creationTime = view.creationTime();
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
String cTime = df.format(creationTime.toMillis());
return cTime;
} catch (Exception e) {
return "--";
}
default:
return null;
}
} else {
if (index < 1)
return ((TreeTableNode) parent).getData()[index];
else
return null;
}
}
return null;
}
示例4: summaryAll
import java.nio.file.attribute.BasicFileAttributes; //導入方法依賴的package包/類
public static void summaryAll() throws IOException{
int sel = jTabbedPane1.getSelectedIndex();
jLabel23.setText(jTabbedPane1.getTitleAt(sel));
jLabel24.setText("File Location : " + titleText.getText());
/**String[] {splitStrings = filesave.getSelectedFile().getName().split("\\.") ;
String extension = splitStrings[splitStrings.length-1] ;
fileext.setText(extension);}**/
jLabel16.setText("File Extention : " + titleExtLa.getText());
JTextArea textPane = (JTextArea) ((JScrollPane) ((JDesktopPane)jTabbedPane1.getComponentAt(sel)).getComponent(0)).getViewport().getComponent(0);
String totaltext= textPane.getText();
String totalwords[]=totaltext.split("\\s");
jLabel21.setText("Total Word Typed : " + totalwords.length);
jLabel5.setText("Total Characters With Spaces : " + totaltext.length());
jLabel22.setText("Total Line : " + BasicEvents.getLineCount(textPane));
if (titleText.getText().contains("Untitled")) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
DateFormat date = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
jLabel27.setText(dateFormat.format(cal.getTime()));
jLabel25.setText(dateFormat.format(cal.getTime()));
} else {
Path filepath = Paths.get(titleText.getText()) ;
BasicFileAttributes attr = Files.readAttributes(filepath, BasicFileAttributes.class);
String dateCreate = ""+attr.creationTime() ; String dateCreat = dateCreate.replace("T", " Time Created : ");
String lastModi = ""+attr.lastModifiedTime() ; String lastMod = lastModi.replace("T", " Last Time Modified : ");
jLabel25.setText("Date Created : " + dateCreat );
jLabel27.setText("Last Date Modified : " + lastMod );
}
}
示例5: getFormattedDate
import java.nio.file.attribute.BasicFileAttributes; //導入方法依賴的package包/類
/**
* Returns formatted date of creation for current file.
* @param path Current file.
* @return Formatted date.
*/
private String getFormattedDate(Path path) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
BasicFileAttributeView faView = Files.getFileAttributeView(path,
BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
BasicFileAttributes attributes = faView.readAttributes();
FileTime fileTime = attributes.creationTime();
return sdf.format(new Date(fileTime.toMillis()));
} catch (IOException e) {
return "";
}
}