0

I'm using a small "xml text based database" to store information. While coding and debugging I had no problems with a method I created, but as an exe file(wrapped with jsmooth), it gives me an error:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: java.io.BufferedReader.lines()LJava/util/stream/Stream: 
      at primary.loadErrorDB(primary.java:471

So i checked line 471 but on Intellij, there is no such error, everything works fine there.

Hope you guys know what to do.

This is the method

    public static Object[] loadErrorDB() {

    File db = new File(System.getProperty("user.dir") + "\\errordb.xml");

    Object[] errordbAry = new String[20][20];

    FileReader file = null;
    try {
        file = new FileReader(db);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    try {
        BufferedReader br = new BufferedReader(file);

        Stream<String> streamList = br.lines();

        errordbAry = streamList.toArray();

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


    String a = "";
    for (Object o : errordbAry) {
        a = a + String.valueOf(o) + ";";
    }

    String[] srgAry = a.split(";");

    String[] newAry = new String[srgAry.length - 5];
    int x = 0;

    for (int i = 5; i < srgAry.length; i++) {
        newAry[x] = srgAry[i];
        x++;
    }

    return newAry;

}
Max Meijer
  • 1,530
  • 1
  • 14
  • 23
MorkTheOrk
  • 13
  • 2

3 Answers3

1
br.lines(); <--BufferedReader don't have method lines() upto Java7 use readLine()

Update Java to Java8 to use this feature.

If You want to read one line at a time use

String line=br.readLine();

Before that make sure that file you are trying to read has line by null check.

String line=null;
if((line=br.readLine())!=null)
  {//Go Ahead
  }

See more one this from BufferedReader

akash
  • 22,664
  • 11
  • 59
  • 87
1

http://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html#lines--

BufferedReader.lines() was added in Java8. Check the version of Java that is being used after packaging with jsmooth.

Chris K
  • 11,622
  • 1
  • 36
  • 49
0

The java.io.BufferedReader class in upto java 7 has readLine() but it dont have the lines() Refer the method. But in java 8 java.io.BufferedReader has the lines() refer for java 8

So first of all check which version of java you have and then proceed accordingly

SparkOn
  • 8,806
  • 4
  • 29
  • 34