Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6095825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:51:23+00:00 2026-05-23T12:51:23+00:00

I have a file with a syntax that looks like this: ! <Group>, Column1,

  • 0

I have a file with a syntax that looks like this:

! <Group>, Column1, column2, column3 
Group, 10, 20, 30
Group, 11, 12, 13
...
! <AnotherGroup>, Column1, column2, column3, column4
AnotherGroup, 10, 20, 30, A
AnotherGroup, 11, 12, 13, B
...

When I try to manipulate the strings through the Scanner object, some strange things are happening such as:

  • end of file is found
  • sometimes does not recognize the character “!” (see code snippet)
  • sometimes does not recognize space characters

        sc = new Scanner(new File("files/myFile"));
    while (sc.hasNextLine()) {
        String tempLine = sc.nextLine();
        if (tempLine.contains("!")) {
            System.out.println(tempLine);
    

Anyway, I think I have to read the entire file and stores it in a specific format in order to manipulate.

Any advices?

Edited after first answer:
This is the case wich sometimes does not recognize the character “!” (see code snippet)

My Sysout:

! <Group1>, Column1, column2, column3 
! <Group2>, Column1, column2, column3 
! <Group5>, Column1, column2, column3

Didnt read the lines with groups 3 and 4

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:51:24+00:00Added an answer on May 23, 2026 at 12:51 pm

    I dont think that there is a problem with the Scanner. At least the part of the code that you have provided should work fine.
    May be verify if you are doing some silly mistake or wait until some gurus come to your help 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml mapping file that looks something like this <colourMappings> <model name=modelX>
I have an XML file (diploma.xml) that looks like this: <?xml version=1.0 standalone=no ?>
I have a file that looks something like this def foo bar {{ //
I have a custom file format for graphs which looks like this: node1.link1 :
I have a gridview that looks something like this: <TemplateColumn> <ItemTemplate> <a href='<%#Eval(FilePathUrl)%>'>FileName</a> </ItemTemplate>
I have an XML that looks like this and a corresponding xsd with it.
All, I have an XML document that looks something like this: <root> <profile> <childA>
I have a system call in Perl that looks like this: system('/path/to/utility >> /redirect/to/log
I've got some JavaScript in an ASP.NET page that looks like this: var list
I have an abstruse sqlldr problem that's bothering me. My control file looks something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.