I want to access all file (name) via http URL. Ex. http://app.examle.com/csv/ so i need to asses all the files (name) present in csv file
headerBaseUrl="http://app.examle.com/csv/stock.csv";
URL br = new URL(headerBaseUrl);
bufferedReader = new BufferedReader(
new InputStreamReader(br.openStream()));
// Create List for holding Employee objects
List<BranchWiseStock> branchWiseStock = new ArrayList<BranchWiseStock>();
String line = "";
// Read to skip the header
bufferedReader.readLine();
// Reading from the second line
while ((line = bufferedReader.readLine()) != null) {
String[] stockDetails = line.split(COMMA_DELIMITER);
if (stockDetails.length > 0) {
System.out.println(" data "+stockDetails);
}
}
Here i can get data of 1 file easily but i want to read multiple files Please help me...!
public class FTPDownloadFileDemo {
public static void main(String args[]) {
String hostname = "XXX";
String username = "XXX";
String password = "XXX";
//Single file download
// String copyFrom = "serverFolderPath/";
// String copyTo = "localPath/";
JSch jsch = new JSch();
Session session = null;
System.out.println("Trying to connect.....");
try {
session = jsch.getSession(username, hostname, 22);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword(password);
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.cd("serverFolderPath/csv/");
Vector<ChannelSftp.LsEntry> list = sftpChannel.ls("*");
for(ChannelSftp.LsEntry entry : list) {
System.out.println("Name :"+entry.getFilename());
}
// sftpChannel.get(copyFrom, copyTo);
sftpChannel.exit();
session.disconnect();
} catch (JSchException e) {
e.printStackTrace();
} catch (SftpException e) {
e.printStackTrace();
}
System.out.println("Done !!");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.