Reputation: 163
i'm working on a program using Jarowinkler method to compare strings..... jaro winkler method gives the values ranging from 0 to 1 based on the similarity of the strings. i have two huge data base files one is acting as a reference and the other is acting as database with duplicates in it. by using the reference file i need to find the original data from the duplicate database file.... here is the error :::
Exception in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at read.main(read.java:66)
here is the program:
import java.util.*;
import java.io.*;
class read
{
public static void main(String args[]) throws IOException
{
int countcolumns=0,countrows=0;
JaroWinkler j=new JaroWinkler();
quicksort e=new quicksort();
PrintWriter out=new PrintWriter("res.txt");
PrintWriter sort=new PrintWriter("sort.txt");
PrintWriter fin=new PrintWriter("resultfinal.txt");
double d=0;int i=0,l=0;
int count=0;
File f=new File("firstlistedited.txt");
Scanner s=new Scanner(f);
//File fil=new File("res.txt");
//Scanner sca=new Scanner(fil);
double r[]=new double[100000];
String a,b,c;
while(s.hasNext())
{
a=s.nextLine();
File fi=new File("result.txt");
Scanner sc=new Scanner(fi);
i=0;
while(sc.hasNext())
{
b =sc.nextLine();
d=j.benzerlikOrani(a,b);
if(d>0.70)
{
r[i]=d;
i++;
//System.out.println("value on comparing "+a +" and "+b+" is "+d);
out.println(a+"/"+b+"="+d);
}
}
quicksort.quicksorts(r, 0, 99999);
//System.out.println(a);
//System.out.println("array is "+r[0]);
sort.println("array is "+r[1]);
sort.println("array is "+r[2]);
sort.println("----------------");
File fil=new File("res.txt");
Scanner sca=new Scanner(fil);
int count1=0;
while(sca.hasNext())
{
count1++;
c =sca.nextLine();
String st="0.00",str="0.00";//,str1="",str2="";
int num=c.length();
for(int x=0;x<num;x++)
{
if(c.charAt(x)=='=')
{
st=c.substring(x+1, num);
//System.out.println(c.substring(x+1, num));
}
}
//-------------------------------------------------------------------------------------
//double dob=Double.valueOf(st.trim()).doubleValue();
double dob=Double.parseDouble(st); //here is the error
//-------------------------------------------------------------------------------------
if(count1>=count)
{
if(r[0]==dob)
{
for(int x=0;x<num;x++)
{
if(c.charAt(x)=='/')
{
str=c.substring(x+1, num);
//String str=c.substring(a.length(),num-a.length()+4);
System.out.println("comparing "+a+" with "+str);
fin.println("comparing "+a+" with "+str);
}
}
}
}
}
count=count1;
System.out.println("------------- ");
}
out.close();
sort.close();
fin.close();
}
}
any help is greatly appreciated..
Upvotes: 1
Views: 4393
Reputation: 346536
Well, at some point when the line the error occurs in is executed, the variable st
holds an empty string. I think this will occur when your file res.txt
contains an empty line, but possibly also in other circumstances. We cannot reproduce it without the input files.
Frankly, this kind of error is exactly what you use a debugger one (before asking people for help). Learn to use one, it will help you immensely in the future.
Upvotes: 3