Home Answers Viewqa Java-Beginners code for recently created file from a folder in java

 
 


siva
code for recently created file from a folder in java
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners

View Answers

December 19, 2008 at 4:28 AM


Hi friend,

Code to help in solving the problem :

import java.io.*;

import java.util.Date;

public class TraversingFileAndDirectories{

public static void main(String args[]){

String dirname = args[0];

long tmp=0;
String fileName="";
try
{
File file = new File(dirname);

if(file.isDirectory()){

System.out.println("Directory is " + dirname);

String str[] = file.list();

for( int i = 0; i<str.length; i++){

File f=new File(dirname + " / " + str[i]);

if(f.isDirectory()){

System.out.println(str[i] + " is a directory");

}

else{

Long lastModified = f.lastModified();
if(lastModified>tmp)
{
tmp = lastModified;
fileName=dirname + " / " + str[i];
}
System.out.println(lastModified);


}

FileInputStream finp=new FileInputStream(fileName);
byte b;
do{
b=(byte)finp.read();
System.out.print((char)b);
}
while(b!=-1);
finp.close();
}

}

else{

System.out.println(dirname + " is not a directory");

}

}
catch (Exception e)
{
System.out.println(e.getMessage());
}


}

}

Thanks









Related Pages:
code for recently created file from a folder in java - Java Beginners
code for recently created file from a folder in java  how to get the recently created file from a folder in java?  Hi friend, Code...=""; try { File file = new File(dirname); if(file.isDirectory
copy file from folder to folder - Java Beginners
copy file from folder to folder   my requirement is I need to copy xml files from one folder to another my source file contains the field filename wich contains the file to be copied. I want to copy the file from
how to download a file from a folder??
how to download a file from a folder??  i can upload any kind of files to a folder, and only the path of the file is saved into the database, now how a client can download the file from my folder. pls provide me the jsp code
Java lock file or folder.
Java lock file or folder.  Is it possible to create a desktop application to lock or encrypt file or folder in windows by using java code?? if possible can provide some reference?? because i can't find it... thanks
Zipping folder - Java Beginners
]; // get a list of files from current directory File f = new File... to zip a user selected folder . this folder may contain any number of folder and sub folders. i saw an example in this site showing , how to zip a folder, i executed
Delete image from folder - JSP-Servlet
when user will logout using java code. anybody having idea about then please...Delete image from folder  Dear All, i used some coding.... that image name based on user id and that image is going to on folder in server after
Delete image from folder - JSP-Servlet
).png if you have any java code for deleting this please send me. not JDBC code...Delete image from folder  Hi Thanks Rajnikant to given me reply i am not storing my image in db just userid comming from db means my
Implementing a Least-Recently-Used(LRU) Cache
the least-recently- used(LRU) cache in Java. LRU Cache helps you how to use... Implementing a Least-Recently-Used(LRU) Cache  ... create a LRU(least-recently-used) Cache and manage it efficiently. Here the given
create table in mysql of split file created in java
create table in mysql of split file created in java  i have created splite file in java. now i want to create table from splited data how to do
Full path of image to save it in a folder
a file but only sends file name as parameter. I want a code that would help me... of either JDBC or JPA, whichever is known to you. 2. saving the file in a folder... as mentioned before or it can be a folder created anywhere in your machine. Hope
How I Choose a folder - Java Interview Questions
do not explain clearly my question. I know how I get files from a folder. My question How I select a folder. From this selected folder i get the files. I know how I get files but the problem How I choose a folder. Thanks
How to access the image file from project folder itself while writing to pdf using itext?
How to access the image file from project folder itself while writing to pdf... it to pick it up from the project folder itself.Because later i deploy the project...:\\company.jpg"); it works fine But when i use this code image = Image.getInstance("items
Image is in same folder where the java file is located - Swing AWT
Image is in same folder where the java file is located  dear sir It is there in the same folder..means the photograph.jpg file is created in the same folder where my java file is present... wat I should do sir
Zip Folder Using Java
in this folder are zipped by using java. Here we will learn how to compress files... objects of File class. In first object we are pass the name of  the folder... to obtain input bytes from a file in a file system. The FileInputStream class
How to upload and save a file in a folder - Java Beginners
and save a file in a folder? for example Agreement.jsp File: So when... should be able to access the file. Can u please tell me the code..  ..., Thanks for your code.... Do i need any jarfiles to be placed in lib? Java
Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
Java Util Zip. Zip files/folders inside a folder, without zipping the original... srcFile, ZipOutputStream zip) throws Exception { File folder = new File... { File folder = new File(srcFolder); for (String fileName : folder.list
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders... in the excel file . To be precise, am working on Java sdk of business objecsts . i need some help in getting folder structure using this java . Folder
How to read PDF files created from Java thru VB Script
How to read PDF files created from Java thru VB Script  We have created the PDF file thru APache FOP but when we are unable to read the data thru... file?   Java PDF Tutorials
Java get Folder Size
File(folder)) Here is the code of GetFolderSize.java... Java get Folder Size     ... presented in the specified folder.  Following code will calculate
Jmagick write image to a specific folder
\newImages. When I compile my code it gets the image from c:\myDirectory\images...Jmagick write image to a specific folder  hi, I am writing the code for resizing the images into which the image will be get from one location
how to upload a file of apk format in a folder from servlet
how to upload a file of apk format in a folder from servlet  How to upload a file of apk format to a folder from servlet, i am trying to do, its getting uploaded as .zip file and not apk file
image save to folder in java
image save to folder in java  Hi, I am working with java. In my... folder and that path stored into database, for furhter retrivation. Please guide me to overcome from that problem Thanks and Regrads Pushpa sheela
downloading created xml file - Java Beginners
downloading created xml file  Hi... I've an application where i need to create an xml file and when a button is clicked it has to prompt me for saving the xml file so i created xml file successfully and whats the problem
jsp directory created in net beans but not able to access
jsp directory created in net beans but not able to access  File f = new File (config.getServletContext().getRealPath("/") + "artists/" +username); f.mkdir(); File video = new File (config.getServletContext().getRealPath
Executing code upon folder/drive access
Executing code upon folder/drive access  I would be glad if someone could show me how to make your program in jar format execute when the folder... of drive you can use Autorun.inf file. In the Autorun.inf file you can include
Export data into CSV File using Servlet
to Export data into  CSV file using Servlet. We have created  file "JdbcCsvFile.java" to export data from this .java file.. Brief... Export data into CSV File using Servlet  
How to copy files from one folder to another based on lastmodified date - Java Beginners
How to copy files from one folder to another based on lastmodified date  I have to make a simple utility to copy files from a folder to another folder in the same hierarchy, without overwriting the existing.  hiimport
Java Write To File From String
Java Write To File From String In this tutorial you will learn how to write to file from string. Write to file from string using java at first we will have... in which I have created a new text file using the File constructor
Count characters from text file in Java
is a java code that count the occurrence of each character from text file. import...Count characters from text file in Java  At the "Count chracters fro mtext file in Java". I tried to run the code, but the error at the line have
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?  i have multiple(app..100) text... column value that keeps on changing for every file.i have read the data from all
Java Write To File From FileInputStream
Java Write To File From FileInputStream In this tutorial you will learn how to write to file from FileInputStream. Write to file from FileInputStream in java... input bytes from a file or can say it reads the streams of bytes. And to write
java - need code - Java Beginners
folder and same file is paste another folder. i need this code. (java)  hi, I am sending you the code which moves the file from one folder...; hi, I am sending you the code which moves the file from one folder
Folder in Java.
Folder in Java.  I have any problem how to make Folder in java program? Can Anybody help me in this part
Insert data in Excel File from Database using JSP
Insert data in Excel File from Database  using JSP ... developed a application to insert data  in excel file from database in JSP. We... the data from database, create an excel file and data insert into newly
Character from text file - Java Beginners
Character from text file  Write a program that reads characters from a text file. Your program will count how many time each character appear...: ?The contents of a string cannot be changed once the string is created.? Character
Java file from url
Java file from url In this section, you will learn how to convert url to file. Description of code: We have already told you the conversion of file to url... urlstring = "file:///C:/java/examples/data.txt"; URL u = new URL(urlstring
write file in aplication folder with out giving full path - WebSevices
write file in aplication folder with out giving full path  i have a simple java class by the help of this java class i want to write file in application folder with out giving full path like c:/data/aa
Moving file or directory from one directory to another
method to complete the program for moving file or complete folder from specified... Moving file or directory from one directory to another.... This program also asks for the replace folder or file if the mentioned
Java read lines from file
Java read lines from file  Any code example related to Java read lines from file? In my project there is requirement of reading the file line by line... of reading file line by line in Java. Can any one share me the code for reading
Getting Parameter from a css styled jsp file to a java servlet file...
Getting Parameter from a css styled jsp file to a java servlet file...  This is my code.... login page-- <!DOCTYPE html PUBLIC "-//W3C//DTD...; java servlet file-- /* * To change this template, choose Tools
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am running code from eclipse i able to read it but when i am adding that jar file
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am running code from eclipse i able to read it but when i am adding that jar file
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database and the file in folder  how to upload multiple files in jsp and saving the path in database and the file in folder I have created a form for the upload of files
java code - Java Beginners
or into microsoft power point using java?????plzzz insert its java code...-bin-3.6-20091214.zip After extracting, put the following jar file in the lib folder...java code  there is an error like the headerfiles does not exists(poi
file
a code but is false in this programm i want make tree with java but i should read data from file. please help me! void maketree(BtNode root,int i) throws... at the following link: Read specific line from file
Accessing XML file from Java
Accessing XML file from Java   ... file using Java Code. In this example we have provided you a simple java...) AccessingXmlFile.java Source Code for accessing XML file through Java  
Getting the modification date and time of file or folder in Java
C:\nisha>java GetDirectoryAndFileModifiedTime Enter file or directory name in proper format to get the modification date and time : myfile.txt File name : myfile.txt File modification date
How can store image in server folder when deployed with a .war file?
How can store image in server folder when deployed with a .war file?  Hi all; When I am using application.getRealPath() , it return null when deployed with a .war file and when I use hard code it shows syntax error or path
create folder
create folder  what code we should write as a web application that it create an empty folder on client's desktop
How to delete file in java ?
How to delete file in java ? In this section we will learn how to write a program to delete a file in java. You can delete the file or folder, java File.... Now, here is the code to delete a file in java. import java.io.File; public

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.