not able to sort textfile input line by line in an output file









up vote
1
down vote

favorite












I ran into a problem. I have written following program to sort string of integers in a text file and output the sorted list of integers in an output file. The input file can contain multiple lines of integers and I want to sort them one line at a time and print it out in my output file.



The problem is program reads all the lines from input text and prints out a continuous line of sorted numbers in the output file. How do I make program sort and print sorted list line by line in output file ?



import java.util.*;

import java.io.File;
import java.io.FileNotFoundException;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class MergeSort  










up vote
1
down vote

favorite












I ran into a problem. I have written following program to sort string of integers in a text file and output the sorted list of integers in an output file. The input file can contain multiple lines of integers and I want to sort them one line at a time and print it out in my output file.



The problem is program reads all the lines from input text and prints out a continuous line of sorted numbers in the output file. How do I make program sort and print sorted list line by line in output file ?



import java.util.*;

import java.io.File;
import java.io.FileNotFoundException;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class MergeSort improve this answer



















    share
    outFile.close();





    share|improve this answer












    You are missing println. Snippet:



     for (int i = 0; i <= intarray.length - 1; i++) 
    outFile.print(intarray[i] + " ");

    outFile.println(); // this is missing
    }
    outFile.close();






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 11 at 1:28









    muradm

    717419




    717419



























         

        draft saved


        draft discarded















































         


        draft saved


        draft discarded














        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244996%2fnot-able-to-sort-textfile-input-line-by-line-in-an-output-file%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

        27

        Top Tejano songwriter Luis Silva dead of heart attack at 64

        Category:Rhetoric