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

 
 


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

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 Pages:
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
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
input output
Program accepts directory name and file extension from user and displays.... The program first accepts directory name and file extension from the user..._file_name); Following code creates the object of FileWriter and BufferedWriter
Name
Name  make a program that take a input from user in alphabet and show all the name of that character E.g User give character "B". The program shows... that starts with particular character The give code takes the input character from
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
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
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
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
Input And Output
accepts directory name and file extension from user and displays the files... directory name and file extension from the user and creates the object of OnlyExt... with an appropriate BufferedReader. Here is the code of java program to Read text File
File Path compare in java
File Path Comparison :compareTo      File Path Comparison :compareTo...;); } } } Output : If both path name are same : Both paths are same
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
how to store image upload path to mssql database
(); } }   Here is a jsp code that allow the user to upload a file and save the file path to database. 1)form.jsp: <%@ page language="java" %> <... To Upload:</b></td> <td><INPUT NAME="file" TYPE="file"><
how to store image upload path to mssql database
(); } }   Here is a jsp code that allow the user to upload a file and save the file path to database. 1)form.jsp: <%@ page language="java" %> <... To Upload:</b></td> <td><INPUT NAME="file" TYPE="file"><
how to store image upload path to mssql database
(); } }   Here is a jsp code that allow the user to upload a file and save the file path to database. 1)form.jsp: <%@ page language="java" %> <... To Upload:</b></td> <td><INPUT NAME="file" TYPE="file"><
how to store image upload path to mssql database
(); } }   Here is a jsp code that allow the user to upload a file and save the file path to database. 1)form.jsp: <%@ page language="java" %> <... To Upload:</b></td> <td><INPUT NAME="file" TYPE="file"><
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
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
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
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
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
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
Getting the Parents of file name path in Java
Getting the Parents of file name path in Java... uses getParent() method of the File class object to find the parent directory name of the current directory.  getParent(): Above code returns the parent
Getting a absolute path
the name of the file whose absolute path you want to know. Now call the method... the absolute path name in  the form of string. Code of the program... the path of the file or directory so that you can access it. If you know the path
input
input  a java program that will exchange the last names of two students that were input by a user
Allow to Enter only numeric data.
that the user should allow to enter only numeric data. I mean to say that if user... for this in java swings. I require a very simple code for this. Plz help...Allow to Enter only numeric data.  hi....... I want to ask
file share to particular user
a file to specific user , how to write code plzzz help. thank you in advance...=rs.getString("file_id"); %> <tr><td><input type="checkbox" name...; <input type="submit" value="Select User"> ShowUser <
Fileupload from source path to destination path
; <td><INPUT NAME="file" TYPE="file"></td> </tr> <tr>... source path &Destination path fields and BOTH INPUT TYPES ARE "TEXT" we... in the destination path like if the source file is .doc it will create a DOC folder
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
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     
input - Java Beginners
to input the data from the command prompt. Try the following code to input name...:"); Scanner input=new Scanner(System.in); String name=input.nextLine...input  i want to know how to take value from user in core java.help
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
Java Path Class
object of which contains the name of a file, directory list to create path, check...() This method is used to get the name of file or directory of the current path...Java Path Class In this section we will discuss all the aspect of Path class
Java file browse
of File class returns the file name from the path. Here is the code: import...Java file browse In this section, you will learn how to browse a file and allows the user to choose a file. Description of code GUI provide File choosers
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
How to create file from input values in Jframe ?
How to create file from input values in Jframe ?  hi i m doing my project using java desktop application in netbeans.i designed a form to get... an object for it.my java code is public class submit { JFrame frame; JTextArea
need code for file browser
need code for file browser  hi, i need to write a code to browse the file in my computer using Jsp or java.. what is the code for file browser... the file To Upload:</b></td> <td><INPUT NAME="file" TYPE="file">
XP Bowling Game User input help
to make the code accept input from a user and display the scores/frames in a command window. Being new to Java....I have no clue how to out put it to the console...XP Bowling Game User input help  I was asked to do the XP Bowling
Managing Multiple User Input Data in an Array (or ArrayList)
Managing Multiple User Input Data in an Array (or ArrayList)  Hey there! I need to make a code of an employee record. Here's how it should work: (1... record alphabetically (2) If user chooses choice1, the input data is stored
Dialog and Console Input-Output
and file input. Of course, your program should eventually have a GUI user..., but it also gets input from the user. 1 2 3 4 5 6 7 8... that also accepts user input. It returns a string that can be stored
java code
with csv format using java/servlet.I would like to download the csv file when user... that upload and save the file into database and allow the user to download that file...;Choose the file To Upload:</b> </td> <td><INPUT NAME="file
Print initials of the input name
Print initials of the input name In this section, you will come to know how to display the initials of the given name. For this, user will have to input... = new Scanner(System.in); System.out.print("Input Name: "); String str
java code
with csv format using java/servlet.I would like to download the csv file when user... that allow the user to upload any file type which then save it to the database... the file To Upload:</b></td> <td><INPUT NAME="file" TYPE="file
Modifying the Path Example.
;hidden" name="posted" value="true"> Enter your file path for cleaning: <input type="text" name="path" size="...Modifying the Path In this example, you will learn how to modify the corrupted
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
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
Console Input: Scanner
Java NotesConsole Input: Scanner The java.util.Scanner class (added in Java 5) allows simple console and file input. Of course, your program should... and read input. System.out.println("What's your name, Earthling

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.