Java - Web Service
Hi,
I wanted a simple java program for web services development as per below:
------ IN REQUEST ------
<FileName>
FileName - Path of the file (For example: C/text.txt)
------ IN RESPONSE --------
<FileName>
<Size>
<Type>
<ReadAccess>
<WriteAccess>
<LastModified>
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
View Answers
May 12, 2012 at 4:17 PM
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);
}
}
Ads
Related Tutorials/Questions & Answers:
Fax service in Java application.
Fax
service in
Java application. Hello,
I want to develop a
Java application to send fax to any destination fax numbers. Anyone who knows about this, please tell how I can do this. Is there any free libraries
Advertisements
Java Message Service(JMS)
Java Message
Service(JMS)
JMS (
Java Message
Service) is a
Java API that allows
java... other.
Java package "javax.jms" provides JMS api. To use JMS, one
Mocking a service that calls another service
Mocking a
service that calls another service I have a method, say m1 in class, say C1. Method m1 calls a method, say m2 from another
service class, say C2. So I mock m2 in junit test-cases for m1. However, m2 itself calls
ModuleNotFoundError: No module named 'service'
ModuleNotFoundError: No module named '
service' Hi,
My Python... '
service'
How to remove the ModuleNotFoundError: No module named '
service... to install padas library.
You can install
service python with following command
unable to open the service tomcat5
unable to open the
service tomcat5 While trying to run tomcat server getting "unable to open the
service tomcat5" error after installed tomcat
restart elasticsearch service centos
restart elasticsearch
service centos Hi
I have elasticsearch server on Centos.
How to restart elasticsearch
service centos?
Thanks
Hi,
In centos elasticserch is installed as
service.
It can be restarted
MongoDB uninstall windows service
the MongoDB on my Winodws Computer as
service. Now I want to uninstall the mongodb from windows
service.
Can any one tell me How to uninstall the MongoDB from windows server?
Thanks
Hi,
You can remove the MongoBD
service using