Hi,
I wanted a simple java program for web services development as per below:
------ IN REQUEST ------
FileName - Path of the file (For example: C/text.txt)
------ IN RESPONSE --------
FileName: This should be filename same as input. Size: size of the file in KB. Type: Type of the file i.e. Java File, ..or anything like. ReadAccess and WriteAccess: Boolean - True or false depending upon access rights. LastModified - Timestamp in the format ddMMyyyy'T'hhmmss
Please help me to get this done.
Thanks
Hi Thanks :)
But I wanted to use this program to create a WSDL file.
I wanted my Web Service request message as
print("<getFileDetailsRequest><file>--Here goes path of a file--</file></getFileDetailsRequest>");
>
Here file is string.
The given code allow the user to input file name with path. The code will then determine the size of file, name of file, last modified date of file. It also check whether the given file is readable or writable.
import javax.swing.*; import java.util.*; import java.text.*; import java.io.*; public class FileOperations{ public static void main(String[]args){ File f=new File("c:/data.txt"); long size=f.length(); String name=f.getName(); JFileChooser chooser = new JFileChooser(); String fileType= chooser.getTypeDescription(f); boolean check1=f.canRead(); boolean check2=f.canWrite(); long s=f.lastModified(); Date d=new Date(s); SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); String lastmodified=sdf.format(d); System.out.println("File Name: "+name); System.out.println("File Type: "+fileType); System.out.println("Is file Readable: "+check1); System.out.println("Is file Writable: "+check2); System.out.println("Last Modified Date: "+lastmodified); } }
And this request message should return response as
print("<getFileDetailsResponse><fileName>--Name of the file --</fileName><type>--File type--</type><size>--size of the file--</size><isReadable>--boolean--<isReadable><isWritable>--boolean--</isWritable><lastModified>--timestamp--</lastModified></getFileDetailsResponse>");
Ads