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

  • Home
  • SEARCH
  • 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 6070065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:53:28+00:00 2026-05-23T09:53:28+00:00

I am writing a java code to write ASCII characters to a file. But

  • 0

I am writing a java code to write ASCII characters to a file. But when I try to write any character of ASCII value of more than 140 or less than 32 to a text file, I get a blank file. It does not write anything to the file. My program is working successfully for all values between 32 and 140. Please help…..
this is the code

public class IO {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    try {
        FileOutputStream fs=new FileOutputStream("C:/Users/Shantanu/Desktop/abc.txt");
        fs.write(143);  
        fs.close();
        System.out.println("finished");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}

  • 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-23T09:53:28+00:00Added an answer on May 23, 2026 at 9:53 am

    When I run this

    final String name = "abc.txt";
    
    FileOutputStream fs = new FileOutputStream(name);
    fs.write(143);
    fs.close();
    
    System.out.println("finished, file.length=" + new File(name).length());
    

    I get

    finished, file.length=1
    

    Since you write 1 byte, you should expect it to be 1 byte long.

    However if you attempt to read this as a UTF-8 or some other encoding, this may be less than 1 character (e.g. in UTF-8 you need 2-3 bytes for characters about 127)

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

Sidebar

Related Questions

Sometimes while writing Java in Eclipse, I write code that generates warnings. A common
I'm writing HTML code for a Java servlet. I first write the code in
I have a created text file in unix enviroment using java code. For writing
I have created a text file in Unix environment using Java code. For writing
am writing a java code that needs to save a file. the below code
I am writing an application java , is any way to write a java
So I am writing a Java code to represent a heap sort and to
I am writing some Java code that authenticates to Active Directory using SASL GSSAPI.
I am writing code in Java where I branch off based on whether a
I am writing a piece of code in Java that needs to take a

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.