the content of my file is the following :
nellkb:company_dc
rdfs:label "dC" "WASHINGTON" , "Washington" ;
skos:prefLabel "www.wikipedia.com" .
nellkb:politicsblog_quami_ekta
rdfs:label "Quami Ekta" ;
skos:prefLabel "Quami Ekta" .
nellkb:female_ramendra_kumar
rdfs:label "Ramendra Kumar" ;
skos:prefLabel "Ramendra Kumar" .
i need to split my file at the delimiter '.' and save what we have before it in a string. How can i do that ? i tried the following but it does not work
try {
String sCurrentLine = null;
int i = 0;
br = new BufferedReader(new FileReader(rdfInstanceFile));
while ((sCurrentLine = br.readLine()) != null) {
splitted = sCurrentLine.split(".");
}
} catch (IOException e) {
e.printStackTrace();
}
USE the Scanner class. This scenario is perfect for it. All you need to do is specify the '\\.' delimiter.
There is no need to build a string AND THEN split it...
import java.io.InputStream;
import java.util.Scanner;
public class ScanFile {
public static void main(String[] args) {
try {
InputStream is = ScanFile.class.getClassLoader().getResourceAsStream("resources/foo.txt");
Scanner scan = new Scanner(is);
scan.useDelimiter("\\.[\r\n]+"); // Tokenize at dots (.) followed by CR/LF.
int i = 1;
while (scan.hasNext()) {
String line = scan.next().trim();
System.out.printf("Line #%d%n-------%n%n%s%n%n", i++, line);
}
scan.close();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output
Line #1
-------
nellkb:company_dc
rdfs:label "dC" "WASHINGTON" , "Washington" ;
skos:prefLabel "WASHINGTON"
Line #2
-------
nellkb:politicsblog_quami_ekta
rdfs:label "Quami Ekta" ;
skos:prefLabel "Quami Ekta"
Line #3
-------
nellkb:female_ramendra_kumar
rdfs:label "Ramendra Kumar" ;
skos:prefLabel "Ramendra Kumar"
Additional Information
useDelimiter
public Scanner useDelimiter(String pattern)
Sets this scanner's delimiting pattern to a pattern constructed from the specified String.
An invocation of this method of the form useDelimiter(pattern) behaves in exactly the same way as the invocation useDelimiter(Pattern.compile(pattern)).
Invoking the reset() method will set the scanner's delimiter to the default.
Parameters:
pattern - A string specifying a delimiting pattern
Returns:
this scanner
The Scanner constructor takes six (6) different types of objects: File, InputStream, Path, Readable, ReadableByteChannel, and String.
// Constructs a new Scanner that produces values scanned from the specified file.
Scanner(File source)
// Constructs a new Scanner that produces values scanned from the specified file.
Scanner(File source, String charsetName)
// Constructs a new Scanner that produces values scanned from the specified input stream.
Scanner(InputStream source)
// Constructs a new Scanner that produces values scanned from the specified input stream.
Scanner(InputStream source, String charsetName)
// Constructs a new Scanner that produces values scanned from the specified file.
Scanner(Path source)
// Constructs a new Scanner that produces values scanned from the specified file.
Scanner(Path source, String charsetName)
// Constructs a new Scanner that produces values scanned from the specified source.
Scanner(Readable source)
// Constructs a new Scanner that produces values scanned from the specified channel.
Scanner(ReadableByteChannel source)
// Constructs a new Scanner that produces values scanned from the specified channel.
Scanner(ReadableByteChannel source, String charsetName)
// Constructs a new Scanner that produces values scanned from the specified string.
Scanner(String source)
Advanced Solution
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ScanFile {
private static ClassLoader loader = ScanFile.class.getClassLoader();
private static interface LineProcessor {
void process(String line);
}
private static interface Reader<T> {
T read(String resource, String delimiter) throws IOException;
void flush();
}
private abstract static class FileScanner<T> implements Reader<T> {
private LineProcessor processor;
public void setProcessor(LineProcessor processor) {
this.processor = processor;
}
public T read(Scanner scan, String delimiter, boolean close) throws IOException {
scan.useDelimiter(delimiter);
while (scan.hasNext()) {
processor.process(scan.next().trim());
}
if (close) {
scan.close();
}
return null;
}
public T read(InputStream is, String delimiter, boolean close) throws IOException {
T t = read(new Scanner(is), delimiter, true);
if (close) {
is.close();
}
return t;
}
public T read(String resource, String delimiter) throws IOException {
return read(loader.getResourceAsStream("resources/" + resource), delimiter, true);
}
}
public static class FileTokenizer extends FileScanner<List<String>> {
private List<String> tokens;
public List<String> getTokens() {
return tokens;
}
public FileTokenizer() {
super();
tokens = new ArrayList<String>();
setProcessor(new LineProcessor() {
#Override
public void process(String token) {
tokens.add(token);
}
});
}
public List<String> read(Scanner scan, String delimiter, boolean close) throws IOException {
super.read(scan, delimiter, close);
return tokens;
}
#Override
public void flush() {
tokens.clear();
}
}
public static void main(String[] args) {
try {
FileTokenizer scanner = new FileTokenizer();
List<String> items = scanner.read("foo.txt", "\\.[\r\n]+");
for (int i = 0; i < items.size(); i++) {
System.out.printf("Line #%d%n-------%n%n%s%n%n", i + 1, items.get(i));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
First read the contents of the file into a string, split the string and save it in a string array.
try {
String sCurrentLine = "";
StringBuilder content = new StringBuilder();
String splitted[]= null;
int i = 0;
br = new BufferedReader(new FileReader(rdfInstanceFile));
while ((sCurrentLine = br.readLine()) != null) {
content.append(sCurrentLine) ;
}
splitted = content.toString().split("\\.");
} catch (IOException e) {
e.printStackTrace();
}
replace
splitted = sCurrentLine.split(".");
with
splitted = sCurrentLine.split("\\.");
EDIT
String sCurrentLine = null;
int i = 0;
br = new BufferedReader(new FileReader(rdfInstanceFile));
StringBuilder content = new StringBuilder();
while ((sCurrentLine = br.readLine()) != null) {
content.append(sCurrentLine);
}
splitted = content.toString().split("\\.");
It'll work.
Related
I am going through Mooc.fi Java course and I can't figure how not to write String into file if the file already contains it. I tried only with one String and tried without " " (empty space), and without another string, but still it adds the string even when the file already contains it.
And translate() method doesn't find/return whole line in which it found the given word.
public class main {
public static void main(String[] args) throws Exception {
MindfulDictionary dict = new MindfulDictionary();
dict.add("apina", "monkey");
dict.add("banaani", "banana");
dict.add("apina", "apfe");
System.out.println( dict.translate("apina") );
System.out.println( dict.translate("monkey") );
System.out.println( dict.translate("programming") );
System.out.println( dict.translate("banana") );
}
}
public class MindfulDictionary {
File file;
FileWriter writer;
Scanner imeskanera;
public MindfulDictionary() throws Exception {
this.file = new File("C:\\Users\\USER\\Desktop\\test.txt");
this.imeskanera = new Scanner(this.file, "UTF-8");
}
public void add(String word, String translation) throws Exception {
boolean found = false;
while(this.imeskanera.hasNextLine()) {
String lineFromFile = this.imeskanera.nextLine();
if(word.contains(lineFromFile)) {
found = true;
break;
}
}
if(!found) {
this.writer = new FileWriter(this.file,true);
this.writer.write(word +" " + translation +"\n");
this.writer.close();
}
}
public String translate(String word) throws Exception {
String line = null;
while(this.imeskanera.hasNextLine()) {
String data = this.imeskanera.nextLine();
if(data.contains(word)) {
line = data;
break;
}
}
return line;
}
}
The problem is that your Scanner object has already been consumed by the add() method. You need to reopen the input stream in order to read the contents of the file. If you add
this.imeskanera = new Scanner(this.file, "UTF-8");
At the beginning of the translate() method, it should word. Which basically tell you that there is no need for Scanner to be a global field. Use it locally in each method. This is how I have explain the concept of file streams in the past:
Think about file streams (for reading and writing) logically. You
cannot allow for such a stream to be "circular". Otherwise, when you
try to get the "next line", there will always be a next line and you
will never be able to stop reading (or writing). The stream is
consumed when it reach the end, and once that is done, to go back to
the beginning of the stream, you will need to open a new one; not
reuse the old one.
I thought I needed to add this explanation even after the answer was accepted because I know new developer struggle with this concept and it because of that, it is necessary to explain it in detail.
With that said, your MindfulDictionary class should look like this:
public class MindfulDictionary {
File file;
FileWriter writer;
// Scanner imeskanera;
public MindfulDictionary() throws Exception {
this.file = new File("test.txt"); // I changed the path to the file to make it work for me. You can change it back if you want to.
file.createNewFile();
}
public void add(String word, String translation) throws Exception {
Scanner imeskanera = new Scanner(this.file, "UTF-8");
boolean found = false;
while (imeskanera.hasNextLine()) {
String lineFromFile = imeskanera.nextLine();
if (word.contains(lineFromFile)) {
found = true;
break;
}
}
if (!found) {
this.writer = new FileWriter(this.file, true);
this.writer.write(word + " " + translation + "\n");
this.writer.close();
}
imeskanera.close();
}
public String translate(String word) throws Exception {
Scanner imeskanera = new Scanner(this.file, "UTF-8");
String line = null;
while (imeskanera.hasNextLine()) {
String data = imeskanera.nextLine();
if (data.contains(word)) {
line = data;
break;
}
}
imeskanera.close();
return line;
}
}
I ran your code with my modifications and now the output is
apina monkey
apina monkey
null
banaani banana
In addition to the Scanner issue mentioned by the answer of #hfontanez, following changes.
if (word.contains(lineFromFile))
This checks if the first word contains the line, this is not true. The file contains the first word and translation. so this can be changed to
if (lineFromFile.contains(word))
as #ghostCat mentioned searching the key(word) can be refactored. Code with these changes.
public class MindfulDictionary {
File file;
FileWriter writer;
// Scanner imeskanera;
public MindfulDictionary() throws Exception {
this.file = new File("test.txt");
file.createNewFile();
}
public void add(String word, String translation) throws Exception {
if (get(word) == null) {
this.writer = new FileWriter(this.file, true);
this.writer.write(word + " " + translation + "\n");
System.out.println("Out>>:"+word + " " + translation + "\n");
this.writer.close();
}
}
private String get(String word) throws Exception {
Scanner imeskanera = new Scanner(this.file, "UTF-8");
boolean found = false;
String retStr= null;
while (imeskanera.hasNextLine()) {
String lineFromFile = imeskanera.nextLine();
if (lineFromFile.contains(word)) {
found = true;
retStr=lineFromFile;
break;
}
}
imeskanera.close();
return(retStr);
}
public String translate(String word) throws Exception {
return get(word);
}
public static void main(String[] args) throws Exception {
MindfulDictionary dict = new MindfulDictionary();
dict.add("apina", "monkey");
dict.add("apina", "monkey");
dict.add("banaani", "banana");
dict.add("apina", "apfe");
System.out.println( dict.translate("apina") );
System.out.println( dict.translate("monkey") );
System.out.println( dict.translate("programming") );
System.out.println( dict.translate("banana") );
}
}
I have this textfile which I like to sort based on HC from the pair HC and P3
This is my file to be sorted (avgGen.txt):
7686.88,HC
20169.22,P3
7820.86,HC
19686.34,P3
6805.62,HC
17933.10,P3
Then my desired output into a new textfile (output.txt) is:
6805.62,HC
17933.10,P3
7686.88,HC
20169.22,P3
7820.86,HC
19686.34,P3
How can I sort the pairs HC and P3 from textfile where HC always appear for odd numbered index and P3 appear for even numbered index but I want the sorting to be ascending based on the HC value?
This is my code:
public class SortTest {
public static void main (String[] args) throws IOException{
ArrayList<Double> rows = new ArrayList<Double>();
ArrayList<String> convertString = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new FileReader("avgGen.txt"));
String s;
while((s = reader.readLine())!=null){
String[] data = s.split(",");
double avg = Double.parseDouble(data[0]);
rows.add(avg);
}
Collections.sort(rows);
for (Double toStr : rows){
convertString.add(String.valueOf(toStr));
}
FileWriter writer = new FileWriter("output.txt");
for(String cur: convertString)
writer.write(cur +"\n");
reader.close();
writer.close();
}
}
Please help.
When you read from the input file, you essentially discarded the string values. You need to retain those string values and associate them with their corresponding double values for your purpose.
You can
wrap the double value and the string value into a class,
create the list using that class instead of the double value alone
Then sort the list based on the double value of the class using either a Comparator or make the class implement Comparable interface.
Print out both the double value and its associated string value, which are encapsulated within a class
Below is an example:
static class Item {
String str;
Double value;
public Item(String str, Double value) {
this.str = str;
this.value = value;
}
}
public static void main (String[] args) throws IOException {
ArrayList<Item> rows = new ArrayList<Item>();
BufferedReader reader = new BufferedReader(new FileReader("avgGen.txt"));
String s;
while((s = reader.readLine())!=null){
String[] data = s.split(",");
double avg = Double.parseDouble(data[0]);
rows.add(new Item(data[1], avg));
}
Collections.sort(rows, new Comparator<Item>() {
public int compare(Item o1, Item o2) {
if (o1.value < o2.value) {
return -1;
} else if (o1.value > o2.value) {
return 1;
}
return 0;
}
});
FileWriter writer = new FileWriter("output.txt");
for(Item cur: rows)
writer.write(cur.value + "," + cur.str + "\n");
reader.close();
writer.close();
}
When your program reads lines from the input file, it splits each line, stores the double portion, and discards the rest. This is because only data[0] is used, while data[1] is not part of any expression.
There are several ways of fixing this. One is to create an array of objects that have the double value and the whole string:
class StringWithSortKey {
public final double key;
public final String str;
public StringWithSortKey(String s) {
String[] data = s.split(",");
key = Double.parseDouble(data[0]);
str = s;
}
}
Create a list of objects of this class, sort them using a custom comparator or by implementing Comparable<StringWithSortKey> interface, and write out str members of sorted objects into the output file.
Define a Pojo or bean representing an well defined/organized/structured data type in the file:
class Pojo implements Comparable<Pojo> {
private double value;
private String name;
#Override
public String toString() {
return "Pojo [value=" + value + ", name=" + name + "]";
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* #param value
* #param name
*/
public Pojo(double value, String name) {
this.value = value;
this.name = name;
}
#Override
public int compareTo(Pojo o) {
return ((Double) this.value).compareTo(o.value);
}
}
then after that: read->sort->store:
public static void main(String[] args) throws IOException {
List<Pojo> pojoList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new FileReader("chat.txt"));
String s;
String[] data;
while ((s = reader.readLine()) != null) {
data = s.split(",");
pojoList.add(new Pojo(Double.parseDouble(data[0]), data[1]));
}
Collections.sort(pojoList);
FileWriter writer = new FileWriter("output.txt");
for (Pojo cur : pojoList)
writer.write(cur.toString() + "\n");
reader.close();
writer.close();
}
Using java-8, there is an easy way of performing this.
public static void main(String[] args) throws IOException {
List<String> lines =
Files.lines(Paths.get("D:\\avgGen.txt"))
.sorted((a, b) -> Integer.compare(Integer.parseInt(a.substring(0,a.indexOf('.'))), Integer.parseInt(b.substring(0,b.indexOf('.')))))
.collect(Collectors.toList());
Files.write(Paths.get("D:\\newFile.txt"), lines);
}
Even better, using a Method reference
public static void main(String[] args) throws IOException {
Files.write(Paths.get("D:\\newFile.txt"),
Files.lines(Paths.get("D:\\avgGen.txt"))
.sorted(Test::compareTheStrings)
.collect(Collectors.toList()));
}
public static int compareTheStrings(String a, String b) {
return Integer.compare(Integer.parseInt(a.substring(0,a.indexOf('.'))), Integer.parseInt(b.substring(0,b.indexOf('.'))));
}
By using double loop sort the items
then just comapre it using the loop and right in the sorted order
public static void main(String[] args) throws IOException {
ArrayList<Double> rows = new ArrayList<Double>();
ArrayList<String> convertString = new ArrayList<String>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("C:/Temp/AvgGen.txt"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String s;
try {
while((s = reader.readLine())!=null){
String[] data = s.split(",");
convertString.add(s);
double avg = Double.parseDouble(data[0]);
rows.add(avg);
}
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
FileWriter writer = new FileWriter("C:/Temp/output.txt");;
Collections.sort(rows);
for (double sorted : rows) {
for (String value : convertString) {
if(Double.parseDouble(value.split(",")[0])==sorted)
{
writer.write(value +"\n");
}
}
}
I've compiled and debugged my program, but there is no output. I suspect an issue passing from BufferedReader to the array method, but I'm not good enough with java to know what it is or how to fix it... Please help! :)
public class Viennaproj {
private String[] names;
private int longth;
//private String [] output;
public Viennaproj(int length, String line) throws IOException
{
this.longth = length;
this.names = new String[length];
String file = "names.txt";
processFile("names.txt",5);
sortNames();
}
public void processFile (String file, int x) throws IOException, FileNotFoundException{
BufferedReader reader = null;
try {
//File file = new File("names.txt");
reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void sortNames()
{
int counter = 0;
int[] lengths = new int[longth];
for( String name : names)
{
lengths[counter] = name.length();
counter++;
}
for (int k = 0; k<longth; k++)
{
int counter2 = k+1;
while (lengths[counter2]<lengths[k]){
String temp2;
int temp;
temp = lengths[counter2];
temp2 = names[counter2];
lengths[counter2] = lengths[k];
names[counter2] = names[k];
lengths[k] = temp;
names[k] = temp2;
counter2++;
}
}
}
public String toString()
{
String output = new String();
for(String name: names)
{
output = name + "/n" + output;
}
return output;
}
public static void main(String[] args)
{
String output = new String ();
output= output.toString();
System.out.println(output+"");
}
}
In Java, the public static void main(String[] args) method is the starting point of the application.
You should create an object of Viennaproj in your main method. Looking at your implementation, just creating an object of Viennaproj will fix your code.
Your main method should look like below
public static void main(String[] args) throws IOException
{
Viennaproj viennaproj = new Viennaproj(5, "Sample Line");
String output= viennaproj.toString();
System.out.println(output);
}
And, if you are getting a FileNotFound exception when you execute this, it means that java is not able to find the file.
You must provide complete file path of your file to avoid that issue. (eg: "C:/test/input.txt")
I am new at Java and I am having a little trouble:
I am trying to read chemical samples to represent them at a X-Y graph.
The input file looks like this:
La 0.85678
Ce 0.473
Pr 62.839
...
...
My code stocks only the unpair lines value (0.85678, jumps line, 62.839 at the example), and I cannot realize what is the problem:
public class Procces {
public void readREE() throws IOException {
try{
rEE = new BufferedReader (new FileReader ("src/files/test.txt"));
while ( (currentLine = rEE.readLine() ) != null) {
try {
for (int size = 3;size<10;size++) {
String valueDec=(currentLine.substring(3,size));
//char letra =(char)c;
if ((c=rEE.read()) != -1) {
System.out.println("Max size");
} else
valueD = Double.parseDouble(valueDec);
System.out.println(valueDec);
}
}
catch (Exception excUncertainDecimals) {
}
}
}finally {
try { rEE.close();
} catch (Exception exc) {
}
}
}
String line;
int c = 0;
int counter = 0;
String valueS = null;
String valueSimb = null;
Double valueD = null;
Double logValue = null;
Double YFin=450.0;
String currentLine;
BufferedReader rEE;
}
Thank you in advance, as I can't see why the program jumps the pair lines.
use Java Scanner class.
import java.io.*;
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) throws IOException {
try (Scanner s = new Scanner(new BufferedReader(new FileReader("file.txt"))){
while (s.hasNext()) {
System.out.println(s.next());
}
}
}
}
Please have a look at Scanner.
In general is Java a well established language and in most cases you do not have to re-implemented "common" (e.g. reading custom text files) stuff on a low level way.
I get it. Thank you.
Here the code:
import java.io.*
import java.util.Scanner;
public class Process implements Samples{
public void readREE() throws IOException {
try
(Scanner rEE = new Scanner(new BufferedReader(new FileReader("src/files/test.txt")))){
while (rEE.hasNext()) {
element = rEE.next();
if (element.equals("La")) {
String elementValue = rEE.next();
Double value = Double.parseDouble(elementValue);
Double valueChond = 0.237;
Double valueNorm= value/valueChond;
Double logValue = (Math.log(valueNorm)/Math.log(10));
Double yLog = yOrd - logValue*133.33333333;
Sample NormedSampleLa=new Sample("La",yLog);
sampleREE.add(NormedSampleLa);
}
}
} finally {
}
}
public String LaS, CeS, PrS, NdS, PmS, SmS, EuS, GdS, TbS, DyS, HoS, ErS, TmS, YbS, LuS;
public String element, elementValue;
public Double yOrd=450.0;
}
I'm working on a homework assignment and have run into an odd "ArrayOutOfBoundsException" error - I know what the error means (essentially I'm trying to reference a location in an array that isn't there) but I'm not sure why it's throwing that error? I'm not sure what I'm missing, but obviously there must be some logic error somewhere that I'm not seeing.
PhoneDirectory.java
import java.util.HashMap;
import java.io.*;
class PhoneDirectory {
private HashMap<String, String> directoryMap;
File directory;
public PhoneDirectory() { //create file for phone-directory
directory = new File("phone-directory.txt");
directoryMap = new HashMap<String, String>();
try(BufferedReader buffer = new BufferedReader(new FileReader(directory))) {
String currentLine;
while((currentLine = buffer.readLine()) != null) { //set currentLine = buffer.readLine() and check if not null
String[] fileData = currentLine.split(","); //create array of values in text file - split by comma
directoryMap.put(fileData[0], fileData[1]); //add item to directoryMap
}
}
catch(IOException err) {
err.printStackTrace();
}
}
public PhoneDirectory(String phoneDirectoryFile) {
directory = new File(phoneDirectoryFile);
directoryMap = new HashMap<String, String>();
try(BufferedReader buffer = new BufferedReader(new FileReader(directory))) {
String currentLine;
while((currentLine = buffer.readLine()) != null) { //set currentLine = buffer.readLine() and check if not null
String[] fileData = currentLine.split(","); //create array of values in text file - split by comma
directoryMap.put(fileData[0], fileData[1]); //add item to directoryMap
}
}
catch(IOException err) {
err.printStackTrace();
}
}
public String Lookup(String personName) {
if(directoryMap.containsKey(personName))
return directoryMap.get(personName);
else
return "This person is not in the directory.";
}
public void AddOrChangeEntry(String name, String phoneNumber) {
//ASK IF "IF-ELSE" CHECK IS NECESSARY
if(directoryMap.containsKey(name))
directoryMap.put(name,phoneNumber); //if name is a key, update listing
else
directoryMap.put(name, phoneNumber); //otherwise - create new entry with name
}
public void DeleteEntry(String name) {
if(directoryMap.containsKey(name))
directoryMap.remove(name);
else
System.out.println("The person you are looking for is not in this directory.");
}
public void Write() {
try(BufferedWriter writeDestination = new BufferedWriter(new FileWriter(directory)))
{
for(String key : directoryMap.keySet())
{
writeDestination.write(key + ", " + directoryMap.get(key) + '\n');
writeDestination.newLine();
}
}
catch(IOException err) {
err.printStackTrace();
}
}
}
Driver.java
public class Driver {
PhoneDirectory list1;
public static void main(String[] args) {
PhoneDirectory list1 = new PhoneDirectory("test.txt");
list1.AddOrChangeEntry("Disney World","123-456-7890");
list1.Write();
}
}
Essentially I'm creating a file called "test.txt" and adding the line "Disney World, 123-456-7890" - what's weird is that the code still works - but it throws me that error anyway, so what's really happening? (For the record, I'm referring to the line(s): directoryMap.put(fileData[0], fileData[1]) - which would be line 14 and 28 respectively.)