File Content Upload using FileReader
| Previous | Home | Next |
Following program for upload the file content form the HardDisk of system by using FileReader and Store into system Buffer memory.
/*
* Save as a FileUpload.java
* Program for Upload file content from a Text file(.txt File).
* File upload from HardDisk, into buffer memory.
*/
package r4r.co.in;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FileUpload {
public static void main(String[] args) {
/*
* Path of the file Store into string.
* System.getProperty() is used for determine the specific property of file.
* Store the file into stringBuffer.
*/
String filename = "C:/R4R/waste.txt";
String string = System.getProperty("File:LINE SEPRATOR");
StringBuffer buffer = new StringBuffer();
try {
/*
* Here, first read the file from fileReader
* Then, load into string buffer
*/
FileReader reader = new FileReader(filename);
BufferedReader br = new BufferedReader(reader);
//read single line from the file, until the null value not get.
System.out.println("Parameter from the file:");
String line;
while ((line = br.readLine()) != null) {
buffer.append(line).append(string);
System.out.println(line.toString());
}
/*
* Multiple catch block used here
* IOExecption generatet, by transfer the file from FileReader to BufferedReader.
* SecurityException generated, by the key value in the .getProperty()
*/
} catch (IOException ioe) {
System.out.println("Exception Caught: " + ioe.getMessage());
} catch(SecurityException se){
System.out.println("Exception Caught: " + se.getMessage());
}
}
}
Parameter from the file:
Advance Java Topic:--ant
Java
Webservice
Syncml
Svn
Struts
Spring
Servers
Salesforce
Rmi
Junit
JspJsf
Jndi
Jms
Jdbc
Javaxml
jasper-reports
j2me
| Previous | Home | Next |