本文整理汇总了Java中java.nio.file.attribute.BasicFileAttributes.lastModifiedTime方法的典型用法代码示例。如果您正苦于以下问题:Java BasicFileAttributes.lastModifiedTime方法的具体用法?Java BasicFileAttributes.lastModifiedTime怎么用?Java BasicFileAttributes.lastModifiedTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.attribute.BasicFileAttributes
的用法示例。
在下文中一共展示了BasicFileAttributes.lastModifiedTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 );
}
}
示例2: createItemAttributes
import java.nio.file.attribute.BasicFileAttributes; //导入方法依赖的package包/类
@Override
@SuppressWarnings("checkstyle:magicnumber")
protected FileItemAttributes createItemAttributes(final File resource) {
FileItemAttributes fia = new FileItemAttributes();
fia.setItemName(resource.getName());
fia.setFilename(resource.getName());
String path = resource.getParent();
if (path != null) {
fia.setPath(path);
}
fia.setItemId(resource.getAbsolutePath());
fia.setSize(resource.length());
List<Long> sizeList = sizes.get(fia.getItemId());
if (sizeList == null) {
sizeList = new ArrayList<Long>(MAX_NUMBER_OF_SIZES);
sizes.put(fia.getItemId(), sizeList);
}
sizeList.add(fia.getSize());
if (sizeList.size() > MAX_NUMBER_OF_SIZES) {
sizeList = sizeList.subList(sizeList.size() - MAX_NUMBER_OF_SIZES, sizeList.size());
}
Long[] sizesArray = new Long[sizeList.size()];
int x = 0;
List<Long> newSizeList = new ArrayList<>();
for (Long l : sizeList) {
sizesArray[x] = l;
x++;
newSizeList.add(l);
}
fia.setSizes(sizesArray);
fia.setSizesList(newSizeList);
fia.setReadonly(Boolean.toString(!resource.canWrite()));
String filePath = resource.getAbsolutePath();
if (latitudes.get(filePath) == null) {
latitudes.put(filePath, 51.5072 + (rand.nextDouble() - 0.25));
longitudes.put(filePath, 0.1275 + (rand.nextDouble() - 0.25));
}
Double latitude = latitudes.get(filePath);
Double longitude = longitudes.get(filePath);
fia.setLatitude(latitude);
fia.setLongitude(longitude);
fia.setCountry("GBR");
BasicFileAttributes attr;
try {
attr = Files.readAttributes(resource.toPath(), BasicFileAttributes.class);
fia.setCreated(attr.creationTime().toString());
if (attr.lastModifiedTime() == null || attr.lastModifiedTime().toString() == null) {
fia.setUpdated(attr.creationTime().toString());
} else {
fia.setUpdated(attr.lastModifiedTime().toString());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return fia;
}