Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java - Web Service code that allow the user to input file name with path

Have Programming Question? Ask it here!
 
 
 


mydocumentsandmails
Java - Web Service code that allow the user to input file name with path
1 Answer(s)      2 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


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


Related Tutorials/Questions & Answers:
Getting ISD code when user input country name
code, from that list i have to read the file and when user input any country name...Getting ISD code when user input country name  I want to create program which user needs by typing Country name he will get ISD code of that country
Constructing a File Name path in Java
Constructing a File Name path        In Java, it is possible to set dynamic path, which is helpful for mapping local  file name with the actual path of the file using
Advertisements
need solution to get file name from path which should give by user
need solution to get file name from path which should give by user  how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name
Constructing a File Name path
Constructing a File Name path   ... construct a file name path. By using the constructing filename path it is possible to set dynamic path, which is helpful for mapping local  file name
Java User Input
Java User Input  I am using Scanner class for user Input. Scanner s = new Scanner(System.in); String name = s.next(); but i am unable to store full name in name variable...how i can store full name plsss reply   use
Getting path name of uploading file in struts 2.8.1
Getting path name of uploading file in struts 2.8.1  Hai! I am using struts 2.8.1. I want to upload file into database with the path name. How can I can get the original path name of the file in struts 2.8.1? It only display
Getting path name of uploading file in struts 2.1.8
Getting path name of uploading file in struts 2.1.8  In my question I used struts 2.8.1 instead of 2.1.8. Sorry
java user input - Java Beginners
java user input  how to input from keyboard? please give a example.  Hi Friend, There are lot of ways to input data from keyboard.You...:****** try{ System.out.print("Enter String:"); BufferedReader input = new
Java Construct File Path
Java Construct File Path In this section we will discuss about how to construct file path in Java. A file path can be constructed manually or by a Java program. It is best practice to construct a file path in Java by a Java Program
user input in java - Java Beginners
user input in java   i am trying to write a code to compute the average of 5 numbers but i dont know what to do for the program to accept user input  Hi import java.util.*; public class AverageExample { public
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... pressing the enter key, you will get the user input. Here is the code
How to get the full path location using <input type=file>
How to get the full path location using input type=file  Hi. I have used input type=file> in HTML to select an image. But it selects only the image but not with its full path location. how to do it? Thanks in advance
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database
How to retrieve file name and path of an excel spreadsheet imported into Oracle... Oracle database and I want to know how to retrieve the path of the file... table for each spreadsheet but I want to obtain the path and filename of each
Java Get File Name
Java Get File Name       In this section, you will study how to obtain the name of file.  In order to get the file name, we have provided the path of file 'Hello.txt
File Path compare in java
File Path Comparison :compareTo      File Path Comparison :compareTo...;); } } } Output : If both path name are same : Both paths are same
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
How to create file and save it into user defined path using jsp/servlet?
How to create file and save it into user defined path using jsp/servlet?  Hi.. Onclick event I have created one file.When file will create it should asked where to save file(like browse option
Java file absolute path
Java file absolute path In this section, you will learn how to get the absolute path of the file. Description of code: If you want to locate a file without... created an object of File class and passed the name of the file as an argument
Java class name and file name are different
Java class name and file name are different  Can we run a Java program having class name and file name different?   Hi Friend, No, you can't. It is necessary to save the java file with its class name otherwise
Convert a file name path to url and vice versa in java
the Filename Path into URL. It reads a file name and converted into the URL. toURL(): The toURL() method of the File class is used to convert the file name... with the toURL() method of the File class. Here is the code of Convert the Filename
No SDK with the name or path
Missing or No SDK with the name or path for XYZ version follow the steps below...No SDK with the name or path  When i run any downloaded application on my mac professional ..it always returns a message no sdk with the name
textfield should not allow the user to fill the date in it.
textfield should not allow the user to fill the date in it.  I got a requirement like this, I am dislaying a text field along with a calendar. Here user should not fill the date inside the text field manually. If he tries
escaping user input in php
escaping user input in php  Is it possible to escape the user input while submitting data into database in PHP
button to accept user input
the radiobutton and spinner.The user input does not show on my Studentinfo.mdb...button to accept user input  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){ public string name,lastname,radiobutton,spinner
calculation after if. user input
user input????   My apologies good evening peoples Once again I am...calculation after if. user input  System.out.print ("please select... addition 5 errors found: File: C:\Users\ Error: variable appleCost might not have
Take input in batch file
Take input in batch file  How to take input in batch file? Thanks   Hi, You can use the following line of code in your batch file: set /p myfile=Enter file name: In the above code myfile variable will hold the data
Java Naming and Directory Interface (JNDI)
service File system JNDI hierarchally organizes its name, these name can be any...) is a directory service based API to allow the clients to discover and lookup data... or for a flat file or for a database for implementation. RMI and Java EE uses
File path for jar file
not found for the template file. Also I had tried to get that path from user...File path for jar file  Hi Experts, I have created one eclipse... path of the template, which is working as per expectation. But I have created
user input to database
user input to database  /* * Studentinfo2App.java */ package...) { } return 0; } } could you plz check what is wrong wit my code because in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package...) { } return 0; } } could you plz check what is wrong wit my code because in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package...) { } return 0; } } could you plz check what is wrong wit my code because in my database user input from my applet does not show
SWT File Browser
, the class FileDialog allow the user to navigate the file system and select a file...;null) {   File file = new File(path);  ... SWT File Browser     
Java file get name
Java file get name In this section, you will learn how to get the name of the file. Description of code: You can see in the given example, we have created... the name of the file. Here is the code: import java.io.*; public class
to retrive e mails as per user name - Java Beginners
to retrive e mails as per user name  hi friends, how to retrive e mails as per user "user name " for ex: class Mail{ private String subject... MailRetriever{ public Mail[] getAllMails(String userName){ //Write code
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. Example:There are two servers 1) Server A and 2) Server B. If a notepad.exe file
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code  hi, I have done a program whereby it can read a Java file and then tokenize them into tokens. However, I am facing
How to read user input in C++
How to read user input in C++  How can i get an input from the users in C++?   You can use the standard input "cin" to get the input from user.. For example: int age; cin >> age
Working With File,Java Input,Java Input Output,Java Inputstream,Java io Tutorial,Java io package,Java io example
;Returns number of bytes in file.  f.getPath()  path name.... The instance of this class represents the name of a file or directory on the host file...  File(path)  Create File object for default directory
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.  write a java program to print marklist of "n " students. input Register number, name and marks of three subjects
How to compile PHP file and provide it to user without code?
How to compile PHP file and provide it to user without code?  I have... in asp.net instead of providing code file. How can I compile the PHP file and provide it to my user in the form dll or may be with other type or extension? Please
why java file save as its class name
why java file save as its class name  hi,this is subbareddy vajrala.my doubt is why java files save as its class names
PHP hide file path
PHP hide file path  PHP to read a path and convert that to the virtual link
Servlet Error Message based on user input
; which renders an input field to enter the name of the user. Here is the code...Servlet Error Message based on user input   ... to check the user input against database and display the message to the user
how do i allow users to download a xls file in html?
how do i allow users to download a xls file in html?  can anyone help me to allow users to download a xls file in html? i tried with href="path...;i tried with href="path/filename.xls click here but it works only in chrome
error in taking input from user.
error in taking input from user.  //i m having problem inputting the array from user.my program is import java.io.*; class bubble { public static void main(String args[]) { int a[]=new int[20]; int i=0; BufferedReader br=new
java code to upload and download a file - Java Beginners
java code to upload and download a file  Is their any java code... store two different files with same path name but content different, ex,in mails, one user send one a.doc file to x ,he has to download his a.doc another
Why doesn't Java allow overriding of static methods?
Why doesn't Java allow overriding of static methods?  Why doesn't Java allow overriding of static methods
Problem in getting file path in js
Problem in getting file path in js  hi, I am using ofbiz framework , How i can get the file path in javascript for input type = "file" and i am using only firefox not other browser. so please help me it is very important for me
java code that monitors the mic input, and dims the screen accordingly
java code that monitors the mic input, and dims the screen accordingly  I know the very basic syntax of java, could someone help me write a code that would constantly analyze the sound being taken in by the mic on the computer
 

 

 

DMCA.com