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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:42:00+00:00 2026-06-08T05:42:00+00:00

I am trying to write a value into a file on the HDFS. Here

  • 0

I am trying to write a value into a file on the HDFS. Here is the code:

FileSystem fsys = FileSystem.get(new Configuration());
        String fileName = "/user/root/TestData/Parameter.txt";
        Path path = new Path(fileName);//(pathOfTestFile);    
//fstatus.getPath();
        FSDataOutputStream fos = null;
        try {
            fos = fsys.create(path);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        BufferedWriter writer = new BufferedWriter(new 
OutputStreamWriter(fos));
        writer.write(iterations);
        writer.close();
        fos.close();

But, I see that the command hadoop fs -ls shows a size of 4 , but when I do a hadoop fs -cat , the file doesn’t show any contents.

  • 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-06-08T05:42:02+00:00Added an answer on June 8, 2026 at 5:42 am

    I’m assuming that iterations is an integer / short / byte. Either way the byte(s) representation of these values is zero or more 0x00 bytes, followed by a 0x04 byte. Neither 0x00 nor 0x04 are printable characters so it’s to no surprise that hadoop fs -cat shows nothing in the output.

    If you pipe the output to hexdump -C though, i imagine you’ll see your output:

    hadoop fs -cat /path/to/file | hexdump -C
    

    EDIT

    You’re also using BufferedWriter.write(int) which actually writes out the int as a chaarcter. You should be using FSDataOutputStream.writeInt(iterations) (it actually is a method of DataOutputStream) and then FSDataInputStream.readInt() to read it back again.

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

Sidebar

Related Questions

I am trying to write a query to insert a value into a timestamp
I'm trying to write the name of the method into a file by adding
I am trying to write a simple regex to match a percentage value range
I'm trying to write a function that can alter the value of a column
I'm trying to write a function : Input: Source range, Source value, output range,
I'm trying to write std::map container where key has 2 values. Here is the
I m trying write code that after reset set up rrpmax as 3000. It
I'm trying to write a Java app that imports a data file. The process
Trying to write a simple C# script to copy file to directory one level
I'm trying to convert a flat file into an Excel-readable format. We receive the

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.