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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:15:39+00:00 2026-06-03T03:15:39+00:00

I have a problem with my bukkit plugin. What I try to do is

  • 0

I have a problem with my bukkit plugin.
What I try to do is search through a file, and read it line by line (that works), then if the line has some text in it, it has to return that line, but it also has to return all the other lines in the file which also have that specific text in it. And when i have these lines, i have to send these lines in a message to the Player, that is not the problem, but when i send the lines i get now, the “\n” doesn’t work, here is the code i use now:

  public String searchText(String text, String file, Player p)
    {
        String data = null;

        try {
            BufferedReader br = new BufferedReader(new FileReader(file));
            String line = null;

            while((line = br.readLine()) != null)
            {
                if(line.indexOf(text) >= 0)
                {
                    data += System.getProperty("line.separator") + line + System.getProperty("line.separator");
                }
                p.sendMessage("+++++++++++GriefLog+++++++++++");
                p.sendMessage(data);
                p.sendMessage("++++++++++GriefLogEnd+++++++++");
            }

            br.close();

        } catch (Exception e) {
            e.printStackTrace();            
        }

        return "";
    }

The return is meant to be empty, because the info is returned to the player a bit higher:P
The problem now is, how do i add an “\n” to the data variable, because when i use this function in the rest of my code, it gives a lot of lines, but without the “\n”, so how do i put that in?

  • 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-03T03:15:40+00:00Added an answer on June 3, 2026 at 3:15 am

    Since your method isn’t supposed to return anything, remove your return statement and set the return type to void.
    It looks like your code would output the data string once for each line your search term occurs, try:

    data = "";
    while((line = br.readLine()) != null)
    {
        if(line.indexOf(text) >= 0)
        {
            //remove the first System.getProperty("line.separator") if
            //you don't want a leading empty line
            data += System.getProperty("line.separator") + line + 
                System.getProperty("line.separator");
        }
    }
    if (data.length() > 0) {
        p.sendMessage("+++++++++++GriefLog+++++++++++");
        p.sendMessage(data);
        p.sendMessage("++++++++++GriefLogEnd+++++++++");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with Activities navigation, searching works good. Activities hierarchy looks like that:
I have problem with passing variables through views. But, first some code // i
I have problem in some JavaScript that I am writing where the Switch statement
i have problem with substitution. I have a file with 1 line of random
have problem with ampersand (&) How to search for the words (or sentences) that
I have problem with fancybox. I want to write a function that will run
i have problem with libhid . i found that there 2 way 4 accessing
I have problem with base classes in WPF. I try to make a base
I have problem with Uploadify: I log in the project using: FormsAuthentication.SetAuthCookie(myName, false); Then,
I have problem when I try to set a background to .header - nothing

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.