Sonal Sharma

Ranch Hand
+ Follow
since May 13, 2006
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sonal Sharma

Hi Brad,
How is it possible to read and update a file at the same time.I don't think its logical to do so.
14 years ago
Dear Ulff,
Yes you are right.This is a ftp client program using libraries from jscape. How to read a text file within remote ftp directory?
My program is this.I have a directory named "Sample Files" on remote ftp server which contains a text file batch2.txt.I want to read that file.Please tell me how to do it.Here is my program:

// only print files that are directories;if(file.isDirectory()) {System.out.println(file.getFilename());String fileName = file.getFilename();String fileName1 = "Sample files";if(fileName.equals(fileName1)){ File fl1 = new File(fileName,"batch2.txt"); try { FileReader fr1 = new FileReader(fl1); BufferedReader br = new BufferedReader(fr1); String s = null; while((s = br.readLine())!=null) System.out.println(s); br.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
14 years ago
Yes you are right Ulff.I am trying to read a text file within a ftp server directory using jscape libraries or jar files.How to do it?
14 years ago
Hi folks,
How about this link:http://www.javaworld.com/channel_content/jw-micro-index.html

Thanks and regards
Hi Kiran,
Can you give a code snippet to use .setBytes() method which formats the file and inserts into the database.

Thanks in advance.
14 years ago
Dear friends
How to read a text file within remote ftp directory?
My program is this.I have a directory named "Sample Files" on remote ftp server which contains a text file batch2.txt.I want to read that file.Please tell me how to do it.Here is my program:


JCE- added code tags
[ April 23, 2008: Message edited by: Joe Ess ]
14 years ago
Dear Rob,
I am asking about the ftp environment.
Here is my program.It is throwing exceptions when I retrieve lastmodifiedtime of a file from an ftp server.
/*
* Main.java
*
* Created on April 23, 2008, 4:41 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/



package javaapplication1;
import com.jscape.inet.ftp.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;


/**
*
* @author Sonal
*/
public class Main {

private static Date lastmodifiedtime;

/** Creates a new instance of Main */
public Main() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Ftp ftp = new Ftp("ftp.FTPplanet.com","anonymous","engineersonal@rediffmail.com");
try {

// establish connection
ftp.connect();
} catch (FtpException ex) {
ex.printStackTrace();
}
String listing = null;
try {
listing = ftp.getDirListingAsString();
// lastmodifiedtime = ftp.getFileTimestamp();
} catch (FtpException ex) {
ex.printStackTrace();
}

// print directory listing to console
System.out.println(listing);
Enumeration files = null;
try {
files = ftp.getDirListing();
// lastmodifiedtime = ftp.getFileTimestamp();
} catch (FtpException ex) {
ex.printStackTrace();
}

// iterate through listing
while(files.hasMoreElements()) {
FtpFile file = (FtpFile)files.nextElement();

// only print files that are directories;
if(file.isDirectory()) {
System.out.println(file.getFilename());
String fileName = file.getFilename();
String fileName1 = "Sample files";
if(fileName.equals(fileName1))
{
File fl1 = new File(fileName,"batch2.txt");
try {
FileReader fr1 = new FileReader(fl1);
BufferedReader br = new BufferedReader(fr1);
String s = null;


while((s = br.readLine())!=null)
System.out.println(s);

br.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}

}
try {
lastmodifiedtime = ftp.getFileTimestamp(file.getFilename());
} catch (FtpException ex) {
ex.printStackTrace();
}

System.out.println(lastmodifiedtime);
System.out.println(file.getFilesize());
//System.out.println(file.getTime());
}
else{
System.out.println(file.getFilename());
System.out.println(file.getFilesize());

try {
lastmodifiedtime = ftp.getFileTimestamp(file.getFilename());
} catch (FtpException ex) {
ex.printStackTrace();
}

System.out.println(lastmodifiedtime);

}
}


// change local directory
ftp.setLocalDir(new File("C:/tmp"));
try {
// change transfer mode to ASCII
ftp.setAscii();
} catch (FtpException ex) {
ex.printStackTrace();
}
try {

// download a file named test.txt in remote directory
ftp.download("batch1.txt");
} catch (FtpException ex) {
ex.printStackTrace();
}

// release the FTP server connection
ftp.disconnect();

/*File file = new File("C:/tmp","batch1.txt");
System.out.println(new Date(file.lastModified()));*/

}

}
14 years ago
How to read the last modified time of a text file or a directory in hh:mm:ss format.
14 years ago
"By which I mean that instead of attempting to do timed data refreshes, simply make a database query on each page request."

There is only one page which is fetching the data from the database after every 5 mins. Please give some code snippet so that I can show the real time report to the user. The database is being updated every 2 mins.

Thanks and regards
14 years ago
JSF
whether I should use ftp or rmi ?
try to use request scope if you want to retain this object for just a request
14 years ago
JSP
Yes all those computers are having ftp access.Do I need to configure my webserver for accesing data on those machines for reading files on those machines or IP addresses.How to do it?
Give some example.Like my web application is deployed on the webserver using JSF on Netbeans with Visual Web Pack.How to access the files in the specified directories on those machines simultaneously like my web application should be able to fetch data from the files on those machines after every 2 secs and upload that data to the database.

Please reply ASAP.
14 years ago
Suppose I have developed a web application which is deployed on the webserver, now our LAN has 6 computers attached.IP Addresses of these computers is known to me. Now this application will keep on fetching the data after every 2 secs from all the PCs in this network, go to a particular folder in each of the computers and read the most recent file and upload its details to the database simultaneously.How to build this kind of application? Totally in a confused state of mind.Some code snippets or tutorials will be of great help.Please reply ASAP.
How should I schedule my JSF application that it fetches the data from the file and upload it in database after every 3 mins.I am using Netbeans with Visual Web Pack.

--Sonal
14 years ago
JSF
When I use a table databound component along with a database as given in Netbeans Visual Web Pack documentation tutorials then what will happen in database transactions that is my main cause of concern?

Reply ASAP.
14 years ago
JSF