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 6983131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:22:42+00:00 2026-05-27T18:22:42+00:00

I have a particular file that Java says is empty… Source Code import java.io.File;

  • 0

I have a particular file that Java says is empty…

Source Code

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

public class MinimumWorkingExample
{
    public static void main(String[] args) throws FileNotFoundException
    {
        String filename = "/home/tyson/Data/English-French_test/test/test.f";
        Scanner fileIn = new Scanner(new File(filename));
        System.out.println("***START***");
        while(fileIn.hasNextLine())
        {
            System.out.println(fileIn.nextLine());
        }
        System.out.println("***FINISH***");
    }
}

Output

***START***
***FINISH***

…but the file is not empty:

Console

tyson@tyson-desktop:~$ head /home/tyson/Data/English-French_test/test/test.f
<s snum=0001> 2 .  </s>
<s snum=0002> 2 .  </s>
<s snum=0003> oh , oh !  </s>
<s snum=0004> oh , oh !  </s>
<s snum=0005> oh , oh !  </s>
<s snum=0006> souvenons - nous , monsieur le Orateur , que ce sont ces secteurs de notre soci�t� qui servent de �pine dorsale � notre �conomie .  </s>
<s snum=0007> bravo !  </s>
<s snum=0008> bravo !  </s>
<s snum=0009> monsieur le Orateur , ma question se adresse � le ministre charg� de les transports .  </s>
<s snum=0010> tous deux poss�dent de nombreuses ann�es de exp�rience dans la fabrication et la distribution de les produits forestiers .  </s>
tyson@tyson-desktop:~$ 

Question

Why is this happening???

  • 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-27T18:22:43+00:00Added an answer on May 27, 2026 at 6:22 pm

    Also do Scanner fileIn = new Scanner(new File(filename), “Cp1252”); as this is the encoding for French, and your system seems to be UTF-8.
    The Scanner might have encoding problems if it thinks to read UTF-8 multibytes.

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

Sidebar

Related Questions

I have a words.txt file that I have put in a particular java package
i have a java code in that i must send a attachment , it
We have a Java application with a particular module that checks if a temporary
I have a program that reads and draws an SVG file in a java
I have a problem downloading particular file types by WebClient. So there are no
Imagine we have a program trying to write to a particular file, but failing.
Greetings, I have a particular object which can be constructed from a file, as
I have a particular PHP page that, for various reasons, needs to save ~200
I have a particular application that needs to calculate something very specific, and while
I have a particular web application that like most others, has to account for

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.