Read in a file, check that it meets certain criteria Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Check that a data file contains the expected number of rows and columns of integersRewriting nested for loops to give better formatted outputJava - How to represent the result of an operationPutting read data into a combined file based on certain attributesCheck whether address criteria contain only certain fields or moreRetrying to read a fileJava 8 file read methodFunction that check's file type based on certain keywordsImplementation of stackImproving this TileMapFollow-up 2: Copy File, remove spaces in specific lines

Echoing a tail command produces unexpected output?

How to find all the available tools in macOS terminal?

What does the word "veer" mean here?

Should I use a zero-interest credit card for a large one-time purchase?

Identify plant with long narrow paired leaves and reddish stems

Coloring maths inside a tcolorbox

Selecting the same column from Different rows Based on Different Criteria

What's the purpose of writing one's academic biography in the third person?

How to deal with a team lead who never gives me credit?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?

Overriding an object in memory with placement new

How do I stop a creek from eroding my steep embankment?

What would be the ideal power source for a cybernetic eye?

illegal generic type for instanceof when using local classes

How widely used is the term Treppenwitz? Is it something that most Germans know?

Fundamental Solution of the Pell Equation

Seeking colloquialism for “just because”

Why did the IBM 650 use bi-quinary?

Is the Standard Deduction better than Itemized when both are the same amount?

Can an alien society believe that their star system is the universe?

What does this icon in iOS Stardew Valley mean?

Generate an RGB colour grid

Bete Noir -- no dairy



Read in a file, check that it meets certain criteria



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Check that a data file contains the expected number of rows and columns of integersRewriting nested for loops to give better formatted outputJava - How to represent the result of an operationPutting read data into a combined file based on certain attributesCheck whether address criteria contain only certain fields or moreRetrying to read a fileJava 8 file read methodFunction that check's file type based on certain keywordsImplementation of stackImproving this TileMapFollow-up 2: Copy File, remove spaces in specific lines



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0












$begingroup$


This was my original posting: Check that a data file contains the expected number of rows and columns of integers



I updated the code. Still what could I improve on?



Another question I have is how come my last method fileContent() does not need any throws declaration in the method header?



import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;

public class FormatChecker2

public static void main(String[] args)
FormatChecker2 tester = new FormatChecker2(); // To avoid every method being static.

if (args.length == 0)
System.out.println("Usage: $ java FormatChecker file1 [file2 ... fileN]");
else
for (String fileName : args)
try
tester.readInTextFile(fileName);
System.out.println(fileName + "");
System.out.println("VALID");
System.out.println();
catch (FileNotFoundException notFound)
System.out.println(notFound.getMessage() + "");
System.out.println(notFound + " (The system cannot find the file specified)");
System.out.println("INVALID");
System.out.println();
catch (NumberFormatException notInt)
System.out.println(fileName);
// String printMessage = notInt.toString().replaceAll("#.*?;", ""); "#" + file +
// ";"
System.out.println(notInt);
System.out.println("INVALID");
System.out.println();
catch (InputMismatchException badContent)
System.out.println(fileName);
System.out.println(badContent);
System.out.println("INVALID");
System.out.println();
catch (IllegalCharacterException delChar)
System.out.println(fileName);
System.out.println(delChar);
System.out.println("INVALID");
System.out.println();






public void readInTextFile(String fileName)
throws FileNotFoundException, IllegalCharacterException, NumberFormatException
File file = new File(fileName);
if (file.exists() && file.isFile())
parseFile(file);
else
throw new FileNotFoundException(fileName);



public void parseFile(File file) throws FileNotFoundException, IllegalCharacterException
Scanner fileScan = new Scanner(file);
String declaredRowCol = fileScan.nextLine().trim();
String[] dimensions = declaredRowCol.split("\s+");
String declaredRowStr = dimensions[0];
String declaredColStr = dimensions[1];
int rowCount = 0;
int colCount = 0;
String notAllNumbers = "";
while (fileScan.hasNextLine())
String line = fileScan.nextLine().trim();
if (!line.isEmpty())
rowCount++;// Counts actual number of rows

Scanner lineScan = new Scanner(line);
while (lineScan.hasNext())
String token = lineScan.next().trim(); // should I include trim?
char letterCheck = token.charAt(0);
// Checks to make sure the content of this file includes only numbers
if (Character.isLetter(letterCheck))
notAllNumbers = letterCheck + "";

colCount++; // Counts actual number of columns, divide by rowCount to get actual

lineScan.close();

// Checks to make sure there is not an extra integer on the first line
if (dimensions.length > 2)
throw new IllegalCharacterException(
"Row and Column have already been provided on the first line of the file. The extra integer: "
+ """ + dimensions[2] + """ + " should not be included.");
else if (!notAllNumbers.isEmpty())
throw new IllegalCharacterException(
"This value in your file: " + """ + notAllNumbers + """ + " is not a number.");
else
formatDimensions(dimensions, declaredRowStr, declaredColStr, rowCount, colCount);



public void formatDimensions(String[] dimensions, String declaredRowStr, String declaredColStr, int rowCount,
int colCount) throws IllegalCharacterException, NumberFormatException, FileNotFoundException

int declaredRow = 0;
int declaredCol = 0;
// Catches if the variables on the first line are of type integer
try
declaredRow = Integer.parseInt(declaredRowStr);
declaredCol = Integer.parseInt(declaredColStr);
fileContent(declaredRow, declaredCol, rowCount, colCount);
catch (NumberFormatException e)
throw new NumberFormatException("This value on the first line of your file:"
+ e.getMessage().substring(17, e.getMessage().length()) + " is not of type integer.");



public void fileContent(int declaredRow, int declaredCol, int rowCount, int colCount)
throws FileNotFoundException, IllegalCharacterException

// Checks to see if row and column matches the actual number of rows and columns
double roundToRealRowCount = (rowCount / 1.0); // This is to account for rounding of
// integer
double roundToRealColCount = (colCount / roundToRealRowCount);// if row or column is not
// divided evenly

if (rowCount != declaredRow)
throw new InputMismatchException("Number of rows declaration: " + "'" + declaredRow + "'"
+ " on first line does not match the actual number of rows in file.");
else if (roundToRealColCount != declaredCol)
throw new InputMismatchException("Number of columns declaration: " + "'" + declaredCol + "'"
+ " on first line does not match the actual number of columns in file.");












share|improve this question











$endgroup$




bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • $begingroup$
    ...but I see fileContent method does have throws clause ....
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:32










  • $begingroup$
    all the printing inside the catch clauses look very similar. should be put in a method.
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:34

















0












$begingroup$


This was my original posting: Check that a data file contains the expected number of rows and columns of integers



I updated the code. Still what could I improve on?



Another question I have is how come my last method fileContent() does not need any throws declaration in the method header?



import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;

public class FormatChecker2

public static void main(String[] args)
FormatChecker2 tester = new FormatChecker2(); // To avoid every method being static.

if (args.length == 0)
System.out.println("Usage: $ java FormatChecker file1 [file2 ... fileN]");
else
for (String fileName : args)
try
tester.readInTextFile(fileName);
System.out.println(fileName + "");
System.out.println("VALID");
System.out.println();
catch (FileNotFoundException notFound)
System.out.println(notFound.getMessage() + "");
System.out.println(notFound + " (The system cannot find the file specified)");
System.out.println("INVALID");
System.out.println();
catch (NumberFormatException notInt)
System.out.println(fileName);
// String printMessage = notInt.toString().replaceAll("#.*?;", ""); "#" + file +
// ";"
System.out.println(notInt);
System.out.println("INVALID");
System.out.println();
catch (InputMismatchException badContent)
System.out.println(fileName);
System.out.println(badContent);
System.out.println("INVALID");
System.out.println();
catch (IllegalCharacterException delChar)
System.out.println(fileName);
System.out.println(delChar);
System.out.println("INVALID");
System.out.println();






public void readInTextFile(String fileName)
throws FileNotFoundException, IllegalCharacterException, NumberFormatException
File file = new File(fileName);
if (file.exists() && file.isFile())
parseFile(file);
else
throw new FileNotFoundException(fileName);



public void parseFile(File file) throws FileNotFoundException, IllegalCharacterException
Scanner fileScan = new Scanner(file);
String declaredRowCol = fileScan.nextLine().trim();
String[] dimensions = declaredRowCol.split("\s+");
String declaredRowStr = dimensions[0];
String declaredColStr = dimensions[1];
int rowCount = 0;
int colCount = 0;
String notAllNumbers = "";
while (fileScan.hasNextLine())
String line = fileScan.nextLine().trim();
if (!line.isEmpty())
rowCount++;// Counts actual number of rows

Scanner lineScan = new Scanner(line);
while (lineScan.hasNext())
String token = lineScan.next().trim(); // should I include trim?
char letterCheck = token.charAt(0);
// Checks to make sure the content of this file includes only numbers
if (Character.isLetter(letterCheck))
notAllNumbers = letterCheck + "";

colCount++; // Counts actual number of columns, divide by rowCount to get actual

lineScan.close();

// Checks to make sure there is not an extra integer on the first line
if (dimensions.length > 2)
throw new IllegalCharacterException(
"Row and Column have already been provided on the first line of the file. The extra integer: "
+ """ + dimensions[2] + """ + " should not be included.");
else if (!notAllNumbers.isEmpty())
throw new IllegalCharacterException(
"This value in your file: " + """ + notAllNumbers + """ + " is not a number.");
else
formatDimensions(dimensions, declaredRowStr, declaredColStr, rowCount, colCount);



public void formatDimensions(String[] dimensions, String declaredRowStr, String declaredColStr, int rowCount,
int colCount) throws IllegalCharacterException, NumberFormatException, FileNotFoundException

int declaredRow = 0;
int declaredCol = 0;
// Catches if the variables on the first line are of type integer
try
declaredRow = Integer.parseInt(declaredRowStr);
declaredCol = Integer.parseInt(declaredColStr);
fileContent(declaredRow, declaredCol, rowCount, colCount);
catch (NumberFormatException e)
throw new NumberFormatException("This value on the first line of your file:"
+ e.getMessage().substring(17, e.getMessage().length()) + " is not of type integer.");



public void fileContent(int declaredRow, int declaredCol, int rowCount, int colCount)
throws FileNotFoundException, IllegalCharacterException

// Checks to see if row and column matches the actual number of rows and columns
double roundToRealRowCount = (rowCount / 1.0); // This is to account for rounding of
// integer
double roundToRealColCount = (colCount / roundToRealRowCount);// if row or column is not
// divided evenly

if (rowCount != declaredRow)
throw new InputMismatchException("Number of rows declaration: " + "'" + declaredRow + "'"
+ " on first line does not match the actual number of rows in file.");
else if (roundToRealColCount != declaredCol)
throw new InputMismatchException("Number of columns declaration: " + "'" + declaredCol + "'"
+ " on first line does not match the actual number of columns in file.");












share|improve this question











$endgroup$




bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • $begingroup$
    ...but I see fileContent method does have throws clause ....
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:32










  • $begingroup$
    all the printing inside the catch clauses look very similar. should be put in a method.
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:34













0












0








0


1



$begingroup$


This was my original posting: Check that a data file contains the expected number of rows and columns of integers



I updated the code. Still what could I improve on?



Another question I have is how come my last method fileContent() does not need any throws declaration in the method header?



import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;

public class FormatChecker2

public static void main(String[] args)
FormatChecker2 tester = new FormatChecker2(); // To avoid every method being static.

if (args.length == 0)
System.out.println("Usage: $ java FormatChecker file1 [file2 ... fileN]");
else
for (String fileName : args)
try
tester.readInTextFile(fileName);
System.out.println(fileName + "");
System.out.println("VALID");
System.out.println();
catch (FileNotFoundException notFound)
System.out.println(notFound.getMessage() + "");
System.out.println(notFound + " (The system cannot find the file specified)");
System.out.println("INVALID");
System.out.println();
catch (NumberFormatException notInt)
System.out.println(fileName);
// String printMessage = notInt.toString().replaceAll("#.*?;", ""); "#" + file +
// ";"
System.out.println(notInt);
System.out.println("INVALID");
System.out.println();
catch (InputMismatchException badContent)
System.out.println(fileName);
System.out.println(badContent);
System.out.println("INVALID");
System.out.println();
catch (IllegalCharacterException delChar)
System.out.println(fileName);
System.out.println(delChar);
System.out.println("INVALID");
System.out.println();






public void readInTextFile(String fileName)
throws FileNotFoundException, IllegalCharacterException, NumberFormatException
File file = new File(fileName);
if (file.exists() && file.isFile())
parseFile(file);
else
throw new FileNotFoundException(fileName);



public void parseFile(File file) throws FileNotFoundException, IllegalCharacterException
Scanner fileScan = new Scanner(file);
String declaredRowCol = fileScan.nextLine().trim();
String[] dimensions = declaredRowCol.split("\s+");
String declaredRowStr = dimensions[0];
String declaredColStr = dimensions[1];
int rowCount = 0;
int colCount = 0;
String notAllNumbers = "";
while (fileScan.hasNextLine())
String line = fileScan.nextLine().trim();
if (!line.isEmpty())
rowCount++;// Counts actual number of rows

Scanner lineScan = new Scanner(line);
while (lineScan.hasNext())
String token = lineScan.next().trim(); // should I include trim?
char letterCheck = token.charAt(0);
// Checks to make sure the content of this file includes only numbers
if (Character.isLetter(letterCheck))
notAllNumbers = letterCheck + "";

colCount++; // Counts actual number of columns, divide by rowCount to get actual

lineScan.close();

// Checks to make sure there is not an extra integer on the first line
if (dimensions.length > 2)
throw new IllegalCharacterException(
"Row and Column have already been provided on the first line of the file. The extra integer: "
+ """ + dimensions[2] + """ + " should not be included.");
else if (!notAllNumbers.isEmpty())
throw new IllegalCharacterException(
"This value in your file: " + """ + notAllNumbers + """ + " is not a number.");
else
formatDimensions(dimensions, declaredRowStr, declaredColStr, rowCount, colCount);



public void formatDimensions(String[] dimensions, String declaredRowStr, String declaredColStr, int rowCount,
int colCount) throws IllegalCharacterException, NumberFormatException, FileNotFoundException

int declaredRow = 0;
int declaredCol = 0;
// Catches if the variables on the first line are of type integer
try
declaredRow = Integer.parseInt(declaredRowStr);
declaredCol = Integer.parseInt(declaredColStr);
fileContent(declaredRow, declaredCol, rowCount, colCount);
catch (NumberFormatException e)
throw new NumberFormatException("This value on the first line of your file:"
+ e.getMessage().substring(17, e.getMessage().length()) + " is not of type integer.");



public void fileContent(int declaredRow, int declaredCol, int rowCount, int colCount)
throws FileNotFoundException, IllegalCharacterException

// Checks to see if row and column matches the actual number of rows and columns
double roundToRealRowCount = (rowCount / 1.0); // This is to account for rounding of
// integer
double roundToRealColCount = (colCount / roundToRealRowCount);// if row or column is not
// divided evenly

if (rowCount != declaredRow)
throw new InputMismatchException("Number of rows declaration: " + "'" + declaredRow + "'"
+ " on first line does not match the actual number of rows in file.");
else if (roundToRealColCount != declaredCol)
throw new InputMismatchException("Number of columns declaration: " + "'" + declaredCol + "'"
+ " on first line does not match the actual number of columns in file.");












share|improve this question











$endgroup$




This was my original posting: Check that a data file contains the expected number of rows and columns of integers



I updated the code. Still what could I improve on?



Another question I have is how come my last method fileContent() does not need any throws declaration in the method header?



import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;

public class FormatChecker2

public static void main(String[] args)
FormatChecker2 tester = new FormatChecker2(); // To avoid every method being static.

if (args.length == 0)
System.out.println("Usage: $ java FormatChecker file1 [file2 ... fileN]");
else
for (String fileName : args)
try
tester.readInTextFile(fileName);
System.out.println(fileName + "");
System.out.println("VALID");
System.out.println();
catch (FileNotFoundException notFound)
System.out.println(notFound.getMessage() + "");
System.out.println(notFound + " (The system cannot find the file specified)");
System.out.println("INVALID");
System.out.println();
catch (NumberFormatException notInt)
System.out.println(fileName);
// String printMessage = notInt.toString().replaceAll("#.*?;", ""); "#" + file +
// ";"
System.out.println(notInt);
System.out.println("INVALID");
System.out.println();
catch (InputMismatchException badContent)
System.out.println(fileName);
System.out.println(badContent);
System.out.println("INVALID");
System.out.println();
catch (IllegalCharacterException delChar)
System.out.println(fileName);
System.out.println(delChar);
System.out.println("INVALID");
System.out.println();






public void readInTextFile(String fileName)
throws FileNotFoundException, IllegalCharacterException, NumberFormatException
File file = new File(fileName);
if (file.exists() && file.isFile())
parseFile(file);
else
throw new FileNotFoundException(fileName);



public void parseFile(File file) throws FileNotFoundException, IllegalCharacterException
Scanner fileScan = new Scanner(file);
String declaredRowCol = fileScan.nextLine().trim();
String[] dimensions = declaredRowCol.split("\s+");
String declaredRowStr = dimensions[0];
String declaredColStr = dimensions[1];
int rowCount = 0;
int colCount = 0;
String notAllNumbers = "";
while (fileScan.hasNextLine())
String line = fileScan.nextLine().trim();
if (!line.isEmpty())
rowCount++;// Counts actual number of rows

Scanner lineScan = new Scanner(line);
while (lineScan.hasNext())
String token = lineScan.next().trim(); // should I include trim?
char letterCheck = token.charAt(0);
// Checks to make sure the content of this file includes only numbers
if (Character.isLetter(letterCheck))
notAllNumbers = letterCheck + "";

colCount++; // Counts actual number of columns, divide by rowCount to get actual

lineScan.close();

// Checks to make sure there is not an extra integer on the first line
if (dimensions.length > 2)
throw new IllegalCharacterException(
"Row and Column have already been provided on the first line of the file. The extra integer: "
+ """ + dimensions[2] + """ + " should not be included.");
else if (!notAllNumbers.isEmpty())
throw new IllegalCharacterException(
"This value in your file: " + """ + notAllNumbers + """ + " is not a number.");
else
formatDimensions(dimensions, declaredRowStr, declaredColStr, rowCount, colCount);



public void formatDimensions(String[] dimensions, String declaredRowStr, String declaredColStr, int rowCount,
int colCount) throws IllegalCharacterException, NumberFormatException, FileNotFoundException

int declaredRow = 0;
int declaredCol = 0;
// Catches if the variables on the first line are of type integer
try
declaredRow = Integer.parseInt(declaredRowStr);
declaredCol = Integer.parseInt(declaredColStr);
fileContent(declaredRow, declaredCol, rowCount, colCount);
catch (NumberFormatException e)
throw new NumberFormatException("This value on the first line of your file:"
+ e.getMessage().substring(17, e.getMessage().length()) + " is not of type integer.");



public void fileContent(int declaredRow, int declaredCol, int rowCount, int colCount)
throws FileNotFoundException, IllegalCharacterException

// Checks to see if row and column matches the actual number of rows and columns
double roundToRealRowCount = (rowCount / 1.0); // This is to account for rounding of
// integer
double roundToRealColCount = (colCount / roundToRealRowCount);// if row or column is not
// divided evenly

if (rowCount != declaredRow)
throw new InputMismatchException("Number of rows declaration: " + "'" + declaredRow + "'"
+ " on first line does not match the actual number of rows in file.");
else if (roundToRealColCount != declaredCol)
throw new InputMismatchException("Number of columns declaration: " + "'" + declaredCol + "'"
+ " on first line does not match the actual number of columns in file.");









java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 19 '17 at 0:09







dporth

















asked Sep 19 '17 at 0:03









dporthdporth

123




123





bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.













  • $begingroup$
    ...but I see fileContent method does have throws clause ....
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:32










  • $begingroup$
    all the printing inside the catch clauses look very similar. should be put in a method.
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:34
















  • $begingroup$
    ...but I see fileContent method does have throws clause ....
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:32










  • $begingroup$
    all the printing inside the catch clauses look very similar. should be put in a method.
    $endgroup$
    – Sharon Ben Asher
    Sep 19 '17 at 6:34















$begingroup$
...but I see fileContent method does have throws clause ....
$endgroup$
– Sharon Ben Asher
Sep 19 '17 at 6:32




$begingroup$
...but I see fileContent method does have throws clause ....
$endgroup$
– Sharon Ben Asher
Sep 19 '17 at 6:32












$begingroup$
all the printing inside the catch clauses look very similar. should be put in a method.
$endgroup$
– Sharon Ben Asher
Sep 19 '17 at 6:34




$begingroup$
all the printing inside the catch clauses look very similar. should be put in a method.
$endgroup$
– Sharon Ben Asher
Sep 19 '17 at 6:34










1 Answer
1






active

oldest

votes


















0












$begingroup$

You could use the split method in the String class to count the columns.



String[] columns = line.split(SEPARATOR);
int colCount = columns.length.





share|improve this answer











$endgroup$













    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: "196"
    ;
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2fcodereview.stackexchange.com%2fquestions%2f176021%2fread-in-a-file-check-that-it-meets-certain-criteria%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    You could use the split method in the String class to count the columns.



    String[] columns = line.split(SEPARATOR);
    int colCount = columns.length.





    share|improve this answer











    $endgroup$

















      0












      $begingroup$

      You could use the split method in the String class to count the columns.



      String[] columns = line.split(SEPARATOR);
      int colCount = columns.length.





      share|improve this answer











      $endgroup$















        0












        0








        0





        $begingroup$

        You could use the split method in the String class to count the columns.



        String[] columns = line.split(SEPARATOR);
        int colCount = columns.length.





        share|improve this answer











        $endgroup$



        You could use the split method in the String class to count the columns.



        String[] columns = line.split(SEPARATOR);
        int colCount = columns.length.






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 19 '18 at 20:30









        Stephen Rauch

        3,77061630




        3,77061630










        answered Aug 19 '18 at 19:56









        fpezzinifpezzini

        1067




        1067



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Code Review Stack Exchange!


            • 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.

            Use MathJax to format equations. MathJax reference.


            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%2fcodereview.stackexchange.com%2fquestions%2f176021%2fread-in-a-file-check-that-it-meets-certain-criteria%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

            名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

            Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

            Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar