What is the simplest way to create a new text file with values from an ArrayList? [closed] Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to write an ArrayList of Strings into a text file?Create ArrayList from arrayFastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?How do I create a Java string from the contents of a file?Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project'Must Override a Superclass Method' Errors after importing a project into EclipseHow do servlets work? Instantiation, sessions, shared variables and multithreadingWhat is simplest way to read a file into String?How to directly initialize a HashMap (in a literal way)?What is the Simplest Way to Reverse an ArrayList?

Output the slug and name of a CPT single post taxonomy term

Can gravitational waves pass through a black hole?

Is my guitar’s action too high?

What came first? Venom as the movie or as the song?

Raising a bilingual kid. When should we introduce the majority language?

“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?

Why do C and C++ allow the expression (int) + 4*5?

How to leave only the following strings?

Assertions In A Mock Callout Test

Are Flameskulls resistant to magical piercing damage?

Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?

Suing a Police Officer Instead of the Police Department

Why these surprising proportionalities of integrals involving odd zeta values?

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

Can this water damage be explained by lack of gutters and grading issues?

Can the van der Waals coefficients be negative in the van der Waals equation for real gases?

Why not use the yoke to control yaw, as well as pitch and roll?

Why aren't road bike wheels tiny?

If gravity precedes the formation of a solar system, where did the mass come from that caused the gravity?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?

FME Console for testing

Lights are flickering on and off after accidentally bumping into light switch

How do I deal with an erroneously large refund?



What is the simplest way to create a new text file with values from an ArrayList? [closed]



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to write an ArrayList of Strings into a text file?Create ArrayList from arrayFastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?How do I create a Java string from the contents of a file?Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project'Must Override a Superclass Method' Errors after importing a project into EclipseHow do servlets work? Instantiation, sessions, shared variables and multithreadingWhat is simplest way to read a file into String?How to directly initialize a HashMap (in a literal way)?What is the Simplest Way to Reverse an ArrayList?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-8















  • I want the text file to be in a particular format which is really what I am getting at.

I am currently looking for a way to create a new text file that is created by using the values from an ArrayList. How do I create a text file that will allow me to have the format that I am looking for?










share|improve this question















closed as primarily opinion-based by Nicholas K, Magnilex, fantaghirocco, jbx, JB Nizet Mar 22 at 14:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 2





    show the code that you tried

    – Deadpool
    Mar 22 at 14:32






  • 1





    1. Search on google how to iterate over a List. 2. Search on google how to write to a file.

    – jbx
    Mar 22 at 14:33






  • 1





    Possible duplicate of How to write an ArrayList of Strings into a text file?

    – fantaghirocco
    Mar 22 at 14:33











  • There are plenty of ways how you can do it, show what you have tried.

    – michalk
    Mar 22 at 14:33












  • "to have the format that I am looking for" Which format?

    – Eritrean
    Mar 22 at 14:44

















-8















  • I want the text file to be in a particular format which is really what I am getting at.

I am currently looking for a way to create a new text file that is created by using the values from an ArrayList. How do I create a text file that will allow me to have the format that I am looking for?










share|improve this question















closed as primarily opinion-based by Nicholas K, Magnilex, fantaghirocco, jbx, JB Nizet Mar 22 at 14:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 2





    show the code that you tried

    – Deadpool
    Mar 22 at 14:32






  • 1





    1. Search on google how to iterate over a List. 2. Search on google how to write to a file.

    – jbx
    Mar 22 at 14:33






  • 1





    Possible duplicate of How to write an ArrayList of Strings into a text file?

    – fantaghirocco
    Mar 22 at 14:33











  • There are plenty of ways how you can do it, show what you have tried.

    – michalk
    Mar 22 at 14:33












  • "to have the format that I am looking for" Which format?

    – Eritrean
    Mar 22 at 14:44













-8












-8








-8








  • I want the text file to be in a particular format which is really what I am getting at.

I am currently looking for a way to create a new text file that is created by using the values from an ArrayList. How do I create a text file that will allow me to have the format that I am looking for?










share|improve this question
















  • I want the text file to be in a particular format which is really what I am getting at.

I am currently looking for a way to create a new text file that is created by using the values from an ArrayList. How do I create a text file that will allow me to have the format that I am looking for?







java arraylist fileinputstream






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 14:34







Eli

















asked Mar 22 at 14:32









EliEli

389




389




closed as primarily opinion-based by Nicholas K, Magnilex, fantaghirocco, jbx, JB Nizet Mar 22 at 14:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as primarily opinion-based by Nicholas K, Magnilex, fantaghirocco, jbx, JB Nizet Mar 22 at 14:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 2





    show the code that you tried

    – Deadpool
    Mar 22 at 14:32






  • 1





    1. Search on google how to iterate over a List. 2. Search on google how to write to a file.

    – jbx
    Mar 22 at 14:33






  • 1





    Possible duplicate of How to write an ArrayList of Strings into a text file?

    – fantaghirocco
    Mar 22 at 14:33











  • There are plenty of ways how you can do it, show what you have tried.

    – michalk
    Mar 22 at 14:33












  • "to have the format that I am looking for" Which format?

    – Eritrean
    Mar 22 at 14:44












  • 2





    show the code that you tried

    – Deadpool
    Mar 22 at 14:32






  • 1





    1. Search on google how to iterate over a List. 2. Search on google how to write to a file.

    – jbx
    Mar 22 at 14:33






  • 1





    Possible duplicate of How to write an ArrayList of Strings into a text file?

    – fantaghirocco
    Mar 22 at 14:33











  • There are plenty of ways how you can do it, show what you have tried.

    – michalk
    Mar 22 at 14:33












  • "to have the format that I am looking for" Which format?

    – Eritrean
    Mar 22 at 14:44







2




2





show the code that you tried

– Deadpool
Mar 22 at 14:32





show the code that you tried

– Deadpool
Mar 22 at 14:32




1




1





1. Search on google how to iterate over a List. 2. Search on google how to write to a file.

– jbx
Mar 22 at 14:33





1. Search on google how to iterate over a List. 2. Search on google how to write to a file.

– jbx
Mar 22 at 14:33




1




1





Possible duplicate of How to write an ArrayList of Strings into a text file?

– fantaghirocco
Mar 22 at 14:33





Possible duplicate of How to write an ArrayList of Strings into a text file?

– fantaghirocco
Mar 22 at 14:33













There are plenty of ways how you can do it, show what you have tried.

– michalk
Mar 22 at 14:33






There are plenty of ways how you can do it, show what you have tried.

– michalk
Mar 22 at 14:33














"to have the format that I am looking for" Which format?

– Eritrean
Mar 22 at 14:44





"to have the format that I am looking for" Which format?

– Eritrean
Mar 22 at 14:44












1 Answer
1






active

oldest

votes


















1














public static void createTextFileFromArrayList()



 List<String> cities = new ArrayList<String>();
cities.addAll(Arrays.asList("Boston", "Washington", "Irving", "Dallas"));

//Get the file reference
Path path = Paths.get("C:\apps\output.txt");

//Use try-with-resource to get auto-closeable writer instance
try (BufferedWriter writer = Files.newBufferedWriter(path))
cities.forEach(city ->
try
writer.write(city);
writer.write("n");
catch (IOException e)
e.printStackTrace();

);
catch (IOException e)
e.printStackTrace();







share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    public static void createTextFileFromArrayList()



     List<String> cities = new ArrayList<String>();
    cities.addAll(Arrays.asList("Boston", "Washington", "Irving", "Dallas"));

    //Get the file reference
    Path path = Paths.get("C:\apps\output.txt");

    //Use try-with-resource to get auto-closeable writer instance
    try (BufferedWriter writer = Files.newBufferedWriter(path))
    cities.forEach(city ->
    try
    writer.write(city);
    writer.write("n");
    catch (IOException e)
    e.printStackTrace();

    );
    catch (IOException e)
    e.printStackTrace();







    share|improve this answer



























      1














      public static void createTextFileFromArrayList()



       List<String> cities = new ArrayList<String>();
      cities.addAll(Arrays.asList("Boston", "Washington", "Irving", "Dallas"));

      //Get the file reference
      Path path = Paths.get("C:\apps\output.txt");

      //Use try-with-resource to get auto-closeable writer instance
      try (BufferedWriter writer = Files.newBufferedWriter(path))
      cities.forEach(city ->
      try
      writer.write(city);
      writer.write("n");
      catch (IOException e)
      e.printStackTrace();

      );
      catch (IOException e)
      e.printStackTrace();







      share|improve this answer

























        1












        1








        1







        public static void createTextFileFromArrayList()



         List<String> cities = new ArrayList<String>();
        cities.addAll(Arrays.asList("Boston", "Washington", "Irving", "Dallas"));

        //Get the file reference
        Path path = Paths.get("C:\apps\output.txt");

        //Use try-with-resource to get auto-closeable writer instance
        try (BufferedWriter writer = Files.newBufferedWriter(path))
        cities.forEach(city ->
        try
        writer.write(city);
        writer.write("n");
        catch (IOException e)
        e.printStackTrace();

        );
        catch (IOException e)
        e.printStackTrace();







        share|improve this answer













        public static void createTextFileFromArrayList()



         List<String> cities = new ArrayList<String>();
        cities.addAll(Arrays.asList("Boston", "Washington", "Irving", "Dallas"));

        //Get the file reference
        Path path = Paths.get("C:\apps\output.txt");

        //Use try-with-resource to get auto-closeable writer instance
        try (BufferedWriter writer = Files.newBufferedWriter(path))
        cities.forEach(city ->
        try
        writer.write(city);
        writer.write("n");
        catch (IOException e)
        e.printStackTrace();

        );
        catch (IOException e)
        e.printStackTrace();








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 14:54









        Raghavendra Kumar BachuRaghavendra Kumar Bachu

        262




        262















            Popular posts from this blog

            How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

            Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?