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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:06:59+00:00 2026-06-03T10:06:59+00:00

I have 3 methods for open file for read file for return things read

  • 0

I have 3 methods

  1. for open file
  2. for read file
  3. for return things read in method read

this my code :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication56;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author x
 */
public class RemoteFileObjectImpl extends java.rmi.server.UnicastRemoteObject  implements RemoteFileObject
{
    public RemoteFileObjectImpl() throws java.rmi.RemoteException {
        super();
    }

    File f = null;
    FileReader r = null;
    BufferedReader bfr = null;

    String output = "";
    public void open(String fileName) {
        //To read file passWord
        f = new File(fileName);
    }
    public String readLine() {
        try {
            String temp = "";
            String newLine = System.getProperty("line.separator");
            r = new FileReader(f);
            while ((temp = bfr.readLine()) != null) {
                output += temp + newLine;
                bfr.close();
            }
        }
        catch (IOException ex) {
           ex.printStackTrace();
        }

        return output;
    }

    public void close() {
        try {
            bfr.close();
        } catch (IOException ex) {
        }
    }

    public static void main(String[]args) throws RemoteException{
        RemoteFileObjectImpl m = new RemoteFileObjectImpl();
        m.open("C:\\Users\\x\\Documents\\txt.txt");
        m.readLine();
        m.close();
    } 
}

But it does not work.

  • 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-03T10:07:01+00:00Added an answer on June 3, 2026 at 10:07 am

    What do you expect it to do, you are not doing anything with the line you read, just

    m.readLine();
    

    Instead:

    String result = m.readLine();
    

    or use the output variable that you saved.

    Do you want to save it to a variable, print it, write it to another file?

    Update: after your update in the comments:
    Your variable bfr is never created/initialized. You are only doing this:

    r = new FileReader(f);
    

    so bfr is still null.

    You should do something like this instead:

    bfr = new BufferedReader(new FileReader(f));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: s(x => x.Open()); s is a method which calls one
if I have methods like function getVar1(){ return $this->var1; } function getVar2(){ return $this->var2;
I have this python code for opening a .cfg file, writing to it and
My site is open to all but i have a controller with some method
I have methods in all of my models that look like this: def formatted_start_date
I have try this code on DatabaseHelper.java Line Number 34 public DatabaseHelper(Context context) throws
I have a small script we're using to read in a CSV file containing
I have a Pylons controller action that needs to return a file to the
I have code using boost to list directory contents, iterate through each file, and
I have to write a program that read from a file that contains 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.