Share on Google+Share on Google+

Java - Web Service
3 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners


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.



View Answers

May 12, 2012 at 5:53 PM

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.

May 12, 2012 at 4:16 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.*;

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);

May 12, 2012 at 6:07 PM

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>");

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
Running Java Applications as a Windows Service
Running Java Applications as a Windows Service  sample code for "Run a Java application as a Windows Service
Servlet service method - Java Beginners
Servlet service method  Hi EveryOne , I have a simple... and the other one is normal java class ,What i want to do is that i want to send path... java class) i want to get this path, i wrote the code for stand alone
minor project on service center management in core java
minor project on service center management in core java  I need a minor project on service center management in core java...If u have then plz send me
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
java program for Denial of Service (DoS) attacks detection - Swing AWT
java program for Denial of Service (DoS) attacks detection  i want a simple program to generate and detect a Denial of Service (DoS) attacks. using java program
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service... is running on Server A,I want to close that service i.e notepad.exe from my remote
Apache Tomcat service error - Java Server Faces Questions
Apache Tomcat service error  Hello Sir,While i am starting the tomcat service i am getting the following error please give me solution. ERROR... information,review the system event log.If this is a non-Microsoft service, contact
servlet Service
servlet Service  Defined servlet Service
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
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
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
Creating a service - JSP-Servlet
the results.The DAO Is written using Hibernate Then I should create a service which...) to get the data back from the database.(Service is a seperate class not like webservice ect) Can anyone tell me how to create a service.   
creating windows service - RMI
service for this server so that it can start/stop at any time. please help me
Doctors Answering Service
Open source forum software in Java/Spring  Open source forum software in Java/Spring
What is the default cache service of hibernate?
What is the default cache service of hibernate?  Hi, What is the default cache service of hibernate? Thanks
GPS Mobile Tracking Service
GPS Mobile Tracking Service The mobile tracking system is currently.... In this response, several companies have begin the mobile tracking service... Global Positioning System (GPS) based mobile tracking service at nominal charges
OS service via bluetooth socket
OS service via bluetooth socket  through bluetooth socket i want to send instructions to the OS, where i dont want any server code for this on my PC or Laptop. My instructions should be handled by the OS inbuilt bluetooth
Difference between httpService and Data Service
Difference between httpService and Data Service  Hi.. Please tell me What is the difference between httpService and Data Service? Thanks  Solution: When we use flex Data Services we have to need
Fetch Gmail Contacts through its service - Java Beginners
Fetch Gmail Contacts through its service  Hello All i want to fetch gmail contacts through there web service in java how can i do. please give me sample code .. Thanking You... Vikram
Fed Ex service (tracking number)
Java Application Server  Java Application Server
service mysql restart: cPanel MYSQL 5.1 to 5.5
service mysql restart: cPanel MYSQL 5.1 to 5.5  service mysql restart: cPanel MYSQL 5.1 to 5.5
Data Service and Query Builder Tool
Data Service and Query Builder Tool       Data Service is more than data manager or data organization, it is data service perspective. It will be able to manage
courier management service (using servlets,jsp,jdbc)
courier management service (using servlets,jsp,jdbc)   is anyone having information about courier management service ? plz share it .its urgent THANKING YOU IN ADVANCE
Service Oriented Architecture
Service Oriented Architecture          Service Oriented Architecture or SOA for short is a new.... In fact service-oriented architecture is collection of many services
clarify bt/w service() and doget/dopost()
clarify bt/w service() and doget/dopost()   Dear friends, i ve question regarding service()and doget/dopost.. the container calls service() where it does the service for the request so then wat is the role of doget/dopost plz
Flex as a Service
Flex as a service? please give me an example if possible Thanks  Ans: Flex is not a server. It is the pert of your web application. you can use flex at server you will use the tomcat or any other web server
Fleet tracking service
There are many fleet tracking service available in the market one can choose... their fleet and maintaining their security. Fleet tracking service acts, as life... whenever the need be. Fleet tracking service have become the spine of fleet
What is software as a service(SaaS)?
for software as a service, means typical software application that is being provided as a service to the clients. Cloud storage is one prominent example of SaaS... distributed to clients as an ongoing service is called as Software as a Service
Service Apartments in Gurgaon
Service Apartments in Gurgaon The city of Gurgaon is one of the upcoming... periods. To provide them with quality accommodation there are some good service... hubs of the city. These service apartments in this high-tech city in the NCR
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null