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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:37:59+00:00 2026-05-26T11:37:59+00:00

I’ve been assigned the task of creating a NIO Persistent Array in my Advanced

  • 0

I’ve been assigned the task of creating a NIO Persistent Array in my “Advanced” Java course. This question is not so much ‘how’ to do this, but ‘what’ is implied by “NIO Persistent”. This is a new concept to me; so far I understand that basically this just means that instead of dynamically storing information in the typical array in code, you store the array’s information on-disk in the form of bytes in pre-determined sized blocks. What I’m confused about is how you get from the information you’re trying to store to bytes, and then how do you write those bytes to a file via Java’s NIO?

TL;DR – Can someone explain a Java NIO Persistent Array in a nutshell? How should I go about constructing one from the ground up?

Thanks for any comments you have in advance!

EDIT: Here is the assignment description, word for word:

Objective

Become familiar with Java’s NIO API.

Requirements

Use Java’s NIO to create a PersistentArray class. The class should
support the following methods:

static void create(String fileName, int bufferSize) – creates an empty
persistent array

static void delete(String fileName) – deletes the persistent array

PersistentArray open(String fileName) – opens the file associated with
the persistent array and prepares the persistent array for gets and
puts.

void put(int bufferID, Buffer buffer) – Stores the buffer at the
bufferID’s location (note that the buffer size must be the same as the
size used when creating the array).

Buffer get(int bufferID) – given the buffer ID, retrieve the buffer
previously stored at the location associated with bufferID.

int getNextID() – return one beyond the maximum ID ever used for
storing a buffer .

void close() – close the file associated with the persistent array

Also, create a JUnit test showing that all methods behave as expected.

Review your work with the instructor.

  • 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-26T11:38:00+00:00Added an answer on May 26, 2026 at 11:38 am

    What:
    There is no such thing like “NIO persistent array”. The instructor wants you to get acquainted with the NIO API (since it’s better and faster than old IO API).

    Now in context to the assignment, you need to implement this class which adheres to the spec specified by the instructor. No fancy stuff, just implement a class which “persists” data (an array in your case) to a file using nio.

    This writeup might help you. File I/O: old I/O or NIO. Which is better?

    TL;DR: There is no special meaning to NIO persistence. Just create an
    array which is not in memory, but also persists its content using NIO.

    How:
    Now, it can be implemented in many ways, Peter’s answer is pretty good where is has recommended to use a RandomAccessFile.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT

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.