Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Java - Web Service

Ads

 
 

Share on Google+Share on Google+

mydocumentsandmails
Java - Web Service
1 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

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

Ads
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
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
Advertisements
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
Version of com.monarchapis>service-java-driver dependency
List of Version of com.monarchapis>service-java-driver dependency
Version of com.bushidowallet>bushido-java-service dependency
List of Version of com.bushidowallet>bushido-java-service dependency
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
Version of com.monarchapis>service-api-java-driver dependency
List of Version of com.monarchapis>service-api-java-driver dependency
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
Maven Dependency bushido-java-service >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.bushidowallet >> bushido-java-service version1.0.0 in your project
Maven Dependency bushido-java-service >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.bushidowallet >> bushido-java-service version1.0.1 in your project
Maven Dependency bushido-java-service >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of com.bushidowallet >> bushido-java-service version1.0.3 in your project
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.   
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
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
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
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
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
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
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
Fed Ex service (tracking number)
Java Application Server  Java Application Server
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
Version of com.notifiermobile>notifier-mobile-service dependency
List of Version of com.notifiermobile>notifier-mobile-service dependency