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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:41:51+00:00 2026-06-10T04:41:51+00:00

I really don’t know, why this is so complex and hard just for reading

  • 0

I really don’t know, why this is so complex and hard just for reading a file with a lot of classes

  • InputStream
  • DataInputStream
  • InputStream
  • BufferReader

What are advantages of below? And what are philosophy at here?

private static String fileToString(String filename) throws IOException
{
    InputStream resourceAsStream;
    resourceAsStream        = "".getClass().getResourceAsStream(filename);
    DataInputStream in      = new DataInputStream(resourceAsStream);
    BufferedReader reader   = new BufferedReader(new InputStreamReader(in));
    StringBuilder builder   = new StringBuilder();
    String line;    
    // For every line in the file, append it to the string builder
    while((line = reader.readLine()) != null)
    {
        builder.append(line);
    }
    return builder.toString();
}
  • 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-10T04:41:52+00:00Added an answer on June 10, 2026 at 4:41 am

    The philosophy is one of flexibility. Using different types of data streams, you can easily read and write different types of data, like bytes, lines of text, or entire user-defined objects, one at a time to and from I/O sources.

    From The Java Tutorials – I/O Streams:

    An I/O Stream represents an input source or an output destination. A stream can represent many different kinds of sources and destinations, including disk files, devices, other programs, and memory arrays.

    Streams support many different kinds of data, including simple bytes, primitive data types, localized characters, and objects. Some streams simply pass on data; others manipulate and transform the data in useful ways.

    Start at the lesson trail Lesson: Basic I/O to get a good overview of Java I/O.


    If you want to see concrete examples of how to simplify I/O for various data types in Java, I recommend having a look at the In.java and Out.java classes from Sedgewick & Wayne’s standard libraries.

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

Sidebar

Related Questions

I really don't know squat about java memory management, so this is entirely my
I really don't know how to explain what's going on, so I'll just show
I really don't know how to title this question, but I need some help
This is a bit complex and I really don't now if it is possible.
I have this json object (which i don't really know what is inside) and
I have this problem and really don't know how to solve this. I'm having
I really don't know how to express this question. But what I'm trying to
I really don't know how to say, may be this is why I didn't
This is one of things that I really don't get. I know that it's
I really don't know what to do anymore... I got this code (tried many

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.