iterate through map and write the content in a separate file
I am trying to save the data from file to a map, then iterate through map and write it to a separate file.My data looks like this:
Concept:Conferences:conferences:confID
Concept:Organizations:organizations:orgID Property:conferencesName:namespace:conferences.Name Property:conferencesDate:namespace:conferences.Date
Here are the steps that I did and planning to perform:
- I wrote a code that reads through the above file and save it in maps depending on if it
is a concept or a property.
Next step would be to create a method that write the lines below into a separate file
that already exists in computer.
map: a d2rq:ClassMap;
map: a d2rq:PropertyBridge;
The last step would be to iterate through the maps and if it is a concept map write the
"key" into the "blank (line 1)" above in step 2 and vice versa for property.
I am new to programming and kind of stuck with steps 2 and 3. Can somebody help me! Please find my code for step 1 here
import java.io.*;
import java.util.*;
public class ReadAndStoreManual {
public static void main(String[] args) {
Map<String, List<String>> conceptMap = new HashMap<String, List<String>>();
Map<String, List<String>> PropertyMap = new HashMap<String, List<String>>();
try{
Scanner scanner = new Scanner(new FileReader("C:/"));
while (scanner.hasNextLine()){
String nextLine = scanner.nextLine();
String [] column = nextLine.split(":");
if (column[0].equals ("Concept")){
if (column.length == 4) {
PropertyMap.put(column [1], Arrays.asList(column[2], column[3]));
}
else {
conceptMap.put (column [1], Arrays.asList (column[2], column[3]));
}
}
}
scanner.close();
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println(conceptMap);
System.out.println(PropertyMap);
}
}
View Answers
Related Tutorials/Questions & Answers:
Advertisements
How to write content of one file to another file.;
In this example we will open a
file and then
write the
content in new
file... is : 1836825431
Content of one
file successfully written in other
file... of the data
being written in the second
file.
About CheckedOutputStream class
how to iterate a map in java using for eachhow to
iterate a
map in java using for each Hi,
I have a HashMap in Java and there is need to
iterate all the items.
how to
iterate a
map in java...;
map = new HashMap<String, String>();
map.put("1", "One
how to iterate a map in java using for eachhow to
iterate a
map in java using for each Hi,
I have a HashMap in Java and there is need to
iterate all the items.
how to
iterate a
map in java...;
map = new HashMap<String, String>();
map.put("1", "One
how to iterate a map in java using for eachhow to
iterate a
map in java using for each Hi,
I have a HashMap in Java and there is need to
iterate all the items.
how to
iterate a
map in java...;
map = new HashMap<String, String>();
map.put("1", "One
Java Map Iterate
Map is an Interface in the Collection Framework.
Map is implemented by its two sub classes
HashMap
Treemap
Map has no iterator method.
So use the entrySet() method.It returns the data as Set
Example of Java
Map How to write in File in JavaHow to
write in
File in Java Hi,
How to
write in
File in Java. Please suggest and give example of this program.
thanks
How to Write to a File in JavaIn this Java tutorial, we will demonstrate how to
write to a
file in Java... to a
file from Java program.
To
write the Java
Write To
File we will use two... and execute it, this will
write "Hello
Java" into out.txt
file. While creating
Read and write fileRead and
write file HI,
How to read and
write file from Java program?
Thanks
Hi,
See the following tutorials:
Java
Write To
File
Read
File
Thanks
How to write file by line in JavaHow to
write file by line in Java How to
write file by line in Java
Hi,
For
Write to a
file by line using java programming language we... in a new line.
How to use
Write To
File By Line in Java programs
Java write to fileJava
write to file How to
write to a
file in Java?
Is there any... files.
You can easily use the the FileWriter and BufferedWriter to
write data to a text
file.
Here is the examples:
Example program to
write to
file.
File How to write in File in JavaHow to
write in
File in Java Hi,
How to
write in
File in Java... bufferedWriter object to
write in the
file.
For more details and examples related to How to
write in
File of Java Program
How to Write to file in Java?How to
Write to
file in Java? How to
Write to
file in Java Program... the Examples of How to
write to
File in Java Program:
WriteToFileExample.java
import... how to
write in a
file.");
br.close();
}
catch (Exception e)
{
System.err.println
Reading Text file and storing in mapReading Text
file and storing in map Hi
I have multiple text files. I want to read thoses files and store those records in
map.
Map will be of "LinkedHashMap<String, Map<String, String>>" type.
Please let me know
Java file read write operationJava
file read
write operation how to read and
write the data from text file.Suppose i have text
file with 4 fields name ,roll no ,marks1,marks2...);
oos.writeObject("Ankit");
oos.writeObject("
Content Writer
changing the file content , reading the
file content and changeing the 501 line
content and crating one... in 501 line but it take lot of time to read all
content of old
file and storing in new
file.
Please help me ,Is there any better logic to chang
content How to write to file using FileOutputStreamHow to
write to
file using FileOutputStream Hi friends,
Please help me in java program.
How to
write to
file using FileOutputStream?
thanks,
Hi,
To
write a
file using FileOutputStream, we have to use
How to Write To File BufferedWriter in JavaHow to
Write To
File BufferedWriter in Java how to
write to
file... in Java.io package i.e. FileWriter and BufferedWriter
file. In this section we... to
write texts. In this classwe stores the character in a buffer to
write how to write file from FileInputStreamhow to
write file from FileInputStream Hi,
How to
Write a
file....
Thanks,
Hi,
For
Write to
file from FileInputStream in java you may use... this website
Write to
file from FileInputStream in java
how to write to file at the end of the linehow to
write to
file at the end of the line Hi,
Where do i learn how to
write to
file at the end of the line using Java program. Plz suggest... will help you for "How to
write the
file at the end of line using Java language
WRITE A PROGRAM TO PRINT OUT THE NUBERS 10 THROUGH 49 WRITE A PROGRAM TO PRINT OUT THE NUBERS 10
THROUGH 49
write a program to print out the number 10
through 49 in the following manner
10 11 12 13 ......19
20 21..............29
30 31..............39
40 4142............49
How to write into CSV file in JavaHow to
write into CSV
file in Java How to
write into CSV
file in Java
Hi,
To create Comma separated value(CSV)
file is very simple... passed the
file name to
write into a stream characters. Then we use the FileWriter
MapMap If I have an object implementing the
Map interface in Java and I wish to
iterate over every pair contained within it, what is the most efficient way of going
through the
map either iterator or for each loop or for loop
how to write append file in Javahow to
write append
file in Java How to
write append
file in Java
Hi,
For append in the test new
file or Appending a text earlier existing
file should be retained when you are trying to
write new contents
How to write to xml file in Java?How to
write to xml
file in Java? Hi Friends,
Can anyone help me how to
write in xml
file in Java programming. Please fill free to give example or reference website for getting example.
Hi,
To
write in xml
file Java Write To File By LineJava
Write To
File By Line
In this tutorial you will learn how to
write to
file by line
Write to a
file by line using java you can use the newLine()
method... how to
write to
file by line. In this example I have first created a new text
Java Write to FileJava
Write to
File
In this tutorial you will learn how to
write to
file in java.
Write to a
file in java we are required to use some classes of java.io... demonstrates you how to
write in a
file.");
br.close();
}
catch (Exception
How to write to file using FileWriterHow to
write to
file using FileWriter hi,
How to
write to
file using FileWriter
thanks,
Hi,
To writing in a
file in Java program we...(
File file), FileWriter(
File file, boolean append), FileWriter(FileDescriptor fd
write excel file into the oracle databasewrite excel
file into the oracle database dear sir,
i need the jsp code that reads the excel
file and stores it into the oracle database table..and also i need the code to connect oracle database?
thank u in advance
Write Text into File
Write Text into
File
... this example we are initialize string to
write into
file. We
are creating
file...
to
write text into
file. At last close output
file using close()
method.ADS
CREATE AND WRITE FILE THREAD JAVACREATE AND
WRITE FILE THREAD JAVA Hi guys I was wondering how can I make this program in java with threads.
I need to create a
file and
write in it (i know how to do that) but by listening in some port all the data that is being
Java Write To File CSVJava
Write To
File CSV
In this tutorial you will learn how to
write to
file... a simple example which will demonstrate you how to
write to
csv
file. To achieve... into which I have passed a
file name to
write a stream of characters. Next I
JavaScript write to text file
JavaScript
write to text
file
... are going to create a
file and
write text into it
using JavaScript.
In the given example... a TextStream object to read from or
write to the
file. The
Boolean value defined