how to read csv file form sftp connection and store into string object in java code and convert into it using rest api

0 votes
May 12 in Java by Pooja
• 120 points

1 answer to this question.

0 votes

Hey, @Pooja,

Before starting with anything you should know the path of the CSV file of the code:

private List<YourJavaItem> processInputFile(String inputFilePath) {

    List<YourJavaItem> inputList = new ArrayList<YourJavaItem>();


      File inputF = new File(inputFilePath);
      InputStream inputFS = new FileInputStream(inputF);
      BufferedReader br = new BufferedReader(new InputStreamReader(inputFS));

      // skip the header of the csv
      inputList = br.lines().skip(1).map(mapToItem).collect(Collectors.toList());
    } catch (FileNotFoundException|IOException e) {

    return inputList ;

Lines(): Which returns a stream object.
skip(1): That skips the first line in the CSV file

answered May 12 by Roshni
• 3,830 points

Related Questions In Java

0 votes
2 answers

How to convert a JSON String into Object in Java?

You could probably check out Google's Gson: ...READ MORE

answered Aug 21, 2019 in Java by Sirajul
• 57,940 points
0 votes
1 answer

How to convert or cast hashmap to JSON object in Java, and again convert JSON object to JSON string?

You can use: new JSONObject(map); READ MORE

answered Jun 27, 2018 in Java by Akrati
• 3,170 points
+15 votes
22 answers

How can I convert String to JSON object in Java?

Hi @Daisy You can use Google gson  for more ...READ MORE

answered Feb 7, 2019 in Java by Suresh
• 720 points
0 votes
2 answers

How can I create File and write data in it using Java?

import; import; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,200 points
0 votes
2 answers

How do I read and convert an InputStream object to string type?

You can also use Java Standard Library ...READ MORE

answered Jul 17, 2018 in Java by Sushmita
• 6,890 points
0 votes
2 answers

How to convert an int array to string using tostring method in java?

Use java.util.Arrays: String res = Arrays.toString(array); System. ...READ MORE

answered Aug 16, 2019 in Java by Sirajul
• 57,940 points
0 votes
1 answer

How to read an XML file using XPath in Java?

Import the packages required to work with ...READ MORE

answered Jun 14, 2018 in Java by Akrati
• 3,170 points
0 votes
0 answers
0 votes
1 answer

How to set path if java is installed in E drive or D drive rather than c

Hello, @Amazing, It doesn't really matter where you ...READ MORE

answered Sep 1 in Java by Roshni
• 3,830 points