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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript