using split() method in an arraylist object the code is incompleteCreate ArrayList from arrayWhen to use LinkedList over ArrayList in Java?Initialization of an ArrayList in one lineSort ArrayList of custom Objects by propertyHow to avoid Java code in JSP files?How to split a string in JavaConverting 'ArrayList<String> to 'String[]' in JavaConvert ArrayList<String> to String[] arrayWhy does this code using random strings print “hello world”?Why is executing Java code in comments with certain Unicode characters allowed?

Does science define life as "beginning at conception"?

How do we explain the use of a software on a math paper?

why "American-born", not "America-born"?

Is there a word for pant sleeves?

If the Charles SSL Proxy shows me sensitive data, is that data insecure/exposed?

Is there a realtime, uncut video of Saturn V ignition through tower clear?

Separate the element after every 2nd ',' and push into next row in bash

Does George B Sperry logo on fold case for photos indicate photographer or case manufacturer?

Way of refund if scammed?

Don't understand notation of morphisms in Monoid definition

How to become an Editorial board member?

Why does an injection from a set to a countable set imply that set is countable?

What's is the easiest way to purchase a stock and hold it

How should I mix small caps with digits or symbols?

How do you cope with rejection?

Story about encounter with hostile aliens

Good examples of "two is easy, three is hard" in computational sciences

Why "strap-on" boosters, and how do other people say it?

How to play vs. 1.e4 e5 2.Nf3 Nc6 3.Bc4 d6?

How to prove the emptiness of intersection of two context free languages is undecidable?

What quantum phenomena violate the superposition principle in electromagnetism?

Germany rejected my entry to Schengen countries

Existence of a model of ZFC in which the natural numbers are really the natural numbers

Why use nominative in Coniugatio periphrastica passiva?



using split() method in an arraylist object the code is incomplete


Create ArrayList from arrayWhen to use LinkedList over ArrayList in Java?Initialization of an ArrayList in one lineSort ArrayList of custom Objects by propertyHow to avoid Java code in JSP files?How to split a string in JavaConverting 'ArrayList<String> to 'String[]' in JavaConvert ArrayList<String> to String[] arrayWhy does this code using random strings print “hello world”?Why is executing Java code in comments with certain Unicode characters allowed?






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








0


















 public static void main(String[] args) throws Exception 
File inputFile = new File("input.txt");
Scanner read = new Scanner(inputFile);
File outputFile = new File("output.txt");
PrintWriter print = new PrintWriter(outputFile);
if (!inputFile.exists())
System.out.println("File does not exist!");

ArrayList<Event> myArray = new ArrayList<>();
String commands="";
while (read.hasNext())
if(commands.matches("AddMovie"))
addMovie(read);







print.flush();
print.close();
read.close();



//java netbeans
public static Event addMovie(Scanner in)
String m[]=new String[6];
for (int i = 0; i < m.length; i++)
String name=in.next();
Date sDate=new Date(in.next());
Date eDate=new Date(in.next());
double price=in.nextDouble();
String city=in.next();
String address=in.next();
String language=in.next();
String tAudience=in.next();
double raiting=in.nextDouble();
int tickets=in.nextInt();


return movie;

 





well I am having a problem here so my program must read from a file these given data



AddMovie--The Upside, 6/3/2019, 6/6/2019, 50, Riyadh, Al Qasr Mall, English, Family, 4.5, 40, Comedy, Nicole Kidman, F, 1967



I have to store them in an ArrayList of object and I have to use non-word characters as a delimiter to split these data should I make a method and inside this method a 1-dimensional array and then use split() method?










share|improve this question
























  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.

    – kozmo
    Mar 23 at 19:39











  • Please share the code that you've tried with so far.

    – Mick Mnemonic
    Mar 23 at 19:40

















0


















 public static void main(String[] args) throws Exception 
File inputFile = new File("input.txt");
Scanner read = new Scanner(inputFile);
File outputFile = new File("output.txt");
PrintWriter print = new PrintWriter(outputFile);
if (!inputFile.exists())
System.out.println("File does not exist!");

ArrayList<Event> myArray = new ArrayList<>();
String commands="";
while (read.hasNext())
if(commands.matches("AddMovie"))
addMovie(read);







print.flush();
print.close();
read.close();



//java netbeans
public static Event addMovie(Scanner in)
String m[]=new String[6];
for (int i = 0; i < m.length; i++)
String name=in.next();
Date sDate=new Date(in.next());
Date eDate=new Date(in.next());
double price=in.nextDouble();
String city=in.next();
String address=in.next();
String language=in.next();
String tAudience=in.next();
double raiting=in.nextDouble();
int tickets=in.nextInt();


return movie;

 





well I am having a problem here so my program must read from a file these given data



AddMovie--The Upside, 6/3/2019, 6/6/2019, 50, Riyadh, Al Qasr Mall, English, Family, 4.5, 40, Comedy, Nicole Kidman, F, 1967



I have to store them in an ArrayList of object and I have to use non-word characters as a delimiter to split these data should I make a method and inside this method a 1-dimensional array and then use split() method?










share|improve this question
























  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.

    – kozmo
    Mar 23 at 19:39











  • Please share the code that you've tried with so far.

    – Mick Mnemonic
    Mar 23 at 19:40













0












0








0











 public static void main(String[] args) throws Exception 
File inputFile = new File("input.txt");
Scanner read = new Scanner(inputFile);
File outputFile = new File("output.txt");
PrintWriter print = new PrintWriter(outputFile);
if (!inputFile.exists())
System.out.println("File does not exist!");

ArrayList<Event> myArray = new ArrayList<>();
String commands="";
while (read.hasNext())
if(commands.matches("AddMovie"))
addMovie(read);







print.flush();
print.close();
read.close();



//java netbeans
public static Event addMovie(Scanner in)
String m[]=new String[6];
for (int i = 0; i < m.length; i++)
String name=in.next();
Date sDate=new Date(in.next());
Date eDate=new Date(in.next());
double price=in.nextDouble();
String city=in.next();
String address=in.next();
String language=in.next();
String tAudience=in.next();
double raiting=in.nextDouble();
int tickets=in.nextInt();


return movie;

 





well I am having a problem here so my program must read from a file these given data



AddMovie--The Upside, 6/3/2019, 6/6/2019, 50, Riyadh, Al Qasr Mall, English, Family, 4.5, 40, Comedy, Nicole Kidman, F, 1967



I have to store them in an ArrayList of object and I have to use non-word characters as a delimiter to split these data should I make a method and inside this method a 1-dimensional array and then use split() method?










share|improve this question



















 public static void main(String[] args) throws Exception 
File inputFile = new File("input.txt");
Scanner read = new Scanner(inputFile);
File outputFile = new File("output.txt");
PrintWriter print = new PrintWriter(outputFile);
if (!inputFile.exists())
System.out.println("File does not exist!");

ArrayList<Event> myArray = new ArrayList<>();
String commands="";
while (read.hasNext())
if(commands.matches("AddMovie"))
addMovie(read);







print.flush();
print.close();
read.close();



//java netbeans
public static Event addMovie(Scanner in)
String m[]=new String[6];
for (int i = 0; i < m.length; i++)
String name=in.next();
Date sDate=new Date(in.next());
Date eDate=new Date(in.next());
double price=in.nextDouble();
String city=in.next();
String address=in.next();
String language=in.next();
String tAudience=in.next();
double raiting=in.nextDouble();
int tickets=in.nextInt();


return movie;

 





well I am having a problem here so my program must read from a file these given data



AddMovie--The Upside, 6/3/2019, 6/6/2019, 50, Riyadh, Al Qasr Mall, English, Family, 4.5, 40, Comedy, Nicole Kidman, F, 1967



I have to store them in an ArrayList of object and I have to use non-word characters as a delimiter to split these data should I make a method and inside this method a 1-dimensional array and then use split() method?






 public static void main(String[] args) throws Exception 
File inputFile = new File("input.txt");
Scanner read = new Scanner(inputFile);
File outputFile = new File("output.txt");
PrintWriter print = new PrintWriter(outputFile);
if (!inputFile.exists())
System.out.println("File does not exist!");

ArrayList<Event> myArray = new ArrayList<>();
String commands="";
while (read.hasNext())
if(commands.matches("AddMovie"))
addMovie(read);







print.flush();
print.close();
read.close();



//java netbeans
public static Event addMovie(Scanner in)
String m[]=new String[6];
for (int i = 0; i < m.length; i++)
String name=in.next();
Date sDate=new Date(in.next());
Date eDate=new Date(in.next());
double price=in.nextDouble();
String city=in.next();
String address=in.next();
String language=in.next();
String tAudience=in.next();
double raiting=in.nextDouble();
int tickets=in.nextInt();


return movie;

 





 public static void main(String[] args) throws Exception 
File inputFile = new File("input.txt");
Scanner read = new Scanner(inputFile);
File outputFile = new File("output.txt");
PrintWriter print = new PrintWriter(outputFile);
if (!inputFile.exists())
System.out.println("File does not exist!");

ArrayList<Event> myArray = new ArrayList<>();
String commands="";
while (read.hasNext())
if(commands.matches("AddMovie"))
addMovie(read);







print.flush();
print.close();
read.close();



//java netbeans
public static Event addMovie(Scanner in)
String m[]=new String[6];
for (int i = 0; i < m.length; i++)
String name=in.next();
Date sDate=new Date(in.next());
Date eDate=new Date(in.next());
double price=in.nextDouble();
String city=in.next();
String address=in.next();
String language=in.next();
String tAudience=in.next();
double raiting=in.nextDouble();
int tickets=in.nextInt();


return movie;

 






java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 3:21









skomisa

7,17642448




7,17642448










asked Mar 23 at 19:38









J.AJ.A

12




12












  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.

    – kozmo
    Mar 23 at 19:39











  • Please share the code that you've tried with so far.

    – Mick Mnemonic
    Mar 23 at 19:40

















  • Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.

    – kozmo
    Mar 23 at 19:39











  • Please share the code that you've tried with so far.

    – Mick Mnemonic
    Mar 23 at 19:40
















Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.

– kozmo
Mar 23 at 19:39





Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.

– kozmo
Mar 23 at 19:39













Please share the code that you've tried with so far.

– Mick Mnemonic
Mar 23 at 19:40





Please share the code that you've tried with so far.

– Mick Mnemonic
Mar 23 at 19:40












2 Answers
2






active

oldest

votes


















0














From what I can understand you are on the right track. Given you read the data you have provided as one single string, you can use the split(",") method on it and store the result of that into an array of strings.






share|improve this answer























  • so i can use an array of string to split data and then store them in arrayList of object?

    – J.A
    Mar 23 at 19:49











  • Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

    – RaMb3asT
    Mar 23 at 19:55


















0














I think that splitting on 'non-word characters' would not be a good idea, as for example you would not want 4.5 to be split into 4 and 5.
I would probably split on ','.
If you were worried about efficiency, it would be a good idea to create a java.util.regex.Pattern object with (for e.g.)



Pattern pat = Pattern.compile(",");


then whenever you wanted to use it, using:



pat.split(theString);





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317627%2fusing-split-method-in-an-arraylist-object-the-code-is-incomplete%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    From what I can understand you are on the right track. Given you read the data you have provided as one single string, you can use the split(",") method on it and store the result of that into an array of strings.






    share|improve this answer























    • so i can use an array of string to split data and then store them in arrayList of object?

      – J.A
      Mar 23 at 19:49











    • Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

      – RaMb3asT
      Mar 23 at 19:55















    0














    From what I can understand you are on the right track. Given you read the data you have provided as one single string, you can use the split(",") method on it and store the result of that into an array of strings.






    share|improve this answer























    • so i can use an array of string to split data and then store them in arrayList of object?

      – J.A
      Mar 23 at 19:49











    • Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

      – RaMb3asT
      Mar 23 at 19:55













    0












    0








    0







    From what I can understand you are on the right track. Given you read the data you have provided as one single string, you can use the split(",") method on it and store the result of that into an array of strings.






    share|improve this answer













    From what I can understand you are on the right track. Given you read the data you have provided as one single string, you can use the split(",") method on it and store the result of that into an array of strings.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 23 at 19:46









    RaMb3asTRaMb3asT

    2118




    2118












    • so i can use an array of string to split data and then store them in arrayList of object?

      – J.A
      Mar 23 at 19:49











    • Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

      – RaMb3asT
      Mar 23 at 19:55

















    • so i can use an array of string to split data and then store them in arrayList of object?

      – J.A
      Mar 23 at 19:49











    • Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

      – RaMb3asT
      Mar 23 at 19:55
















    so i can use an array of string to split data and then store them in arrayList of object?

    – J.A
    Mar 23 at 19:49





    so i can use an array of string to split data and then store them in arrayList of object?

    – J.A
    Mar 23 at 19:49













    Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

    – RaMb3asT
    Mar 23 at 19:55





    Well, the split() method produces an array of strings, which could be then converted to an ArrayList object.

    – RaMb3asT
    Mar 23 at 19:55













    0














    I think that splitting on 'non-word characters' would not be a good idea, as for example you would not want 4.5 to be split into 4 and 5.
    I would probably split on ','.
    If you were worried about efficiency, it would be a good idea to create a java.util.regex.Pattern object with (for e.g.)



    Pattern pat = Pattern.compile(",");


    then whenever you wanted to use it, using:



    pat.split(theString);





    share|improve this answer



























      0














      I think that splitting on 'non-word characters' would not be a good idea, as for example you would not want 4.5 to be split into 4 and 5.
      I would probably split on ','.
      If you were worried about efficiency, it would be a good idea to create a java.util.regex.Pattern object with (for e.g.)



      Pattern pat = Pattern.compile(",");


      then whenever you wanted to use it, using:



      pat.split(theString);





      share|improve this answer

























        0












        0








        0







        I think that splitting on 'non-word characters' would not be a good idea, as for example you would not want 4.5 to be split into 4 and 5.
        I would probably split on ','.
        If you were worried about efficiency, it would be a good idea to create a java.util.regex.Pattern object with (for e.g.)



        Pattern pat = Pattern.compile(",");


        then whenever you wanted to use it, using:



        pat.split(theString);





        share|improve this answer













        I think that splitting on 'non-word characters' would not be a good idea, as for example you would not want 4.5 to be split into 4 and 5.
        I would probably split on ','.
        If you were worried about efficiency, it would be a good idea to create a java.util.regex.Pattern object with (for e.g.)



        Pattern pat = Pattern.compile(",");


        then whenever you wanted to use it, using:



        pat.split(theString);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 19:50









        Bill NaylorBill Naylor

        7117




        7117



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317627%2fusing-split-method-in-an-arraylist-object-the-code-is-incomplete%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현