Home Answers Viewqa Java-Beginners iterate through map and write the content in a separate file

 
 


mahindar
iterate through map and write the content in a separate file
0 Answer(s)      9 months ago
Posted in : Java Beginners

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:

  1. 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.
  2. 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;

  3. 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 Pages:
iterate through map and write the content in a separate file
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... into a separate file that already exists in computer. map: a d2rq:ClassMap
iterate through map and write the content in a separate file
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... into a separate file that already exists in computer. map: a d2rq:ClassMap
iterate through map and write the content in a separate file
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... into a separate file that already exists in computer. map: a d2rq:ClassMap
Map
Map  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
Iterate Tag used with a Map.
Iterate Tag used with a Map.  How Iterate Tag used with a Map
Write a program in Java to append content at the end of an already existing file.
Write a program in Java to append content at the end of an already existing file.  Write a program in Java to append content at the end of an already existing file
How to store two integer value in a separate file and retrieve those values
How to store two integer value in a separate file and retrieve those... with idea of saving those values in a separate file and updating values in file... can i write and update value in that file
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 write content of one file to another file and calculate checksum for accuracy.
on the output stream.  In this Example, we will write the content of a file to another file. And calculate the value of checksum at writing time with the help of CheckedOutputStream class. After it we will read the content of new file
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 to a File in Java without overwriting
overwriting the content of "log.txt" file. Next time if you write... in a text file through your Java program. Program explained here writes the content...Learn how to Write to a File in Java without overwriting in your Java program
Hash Map
Hash Map  how to add the hash map objects in the list and iterate the objects
logic iterate tag - Struts
logic iterate tag  Hey I am displaying the values in a jsp called categoryView.jsp using logic iterate tag as Now properties... CategoryForm.java to ViewCategoryForm.java. How do I separate both of the form beans
Site map - C Tutorials
rename | C file write example | C GMT Time | C Goto Statement | C... | Site Map | Business Software Services India Tutorial Section  ... | C String Copy | C Dynamic Array | C file delete example | C file
How to write file by line in Java
How 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
Overview of Networking through JAVA
Overview of Networking through JAVA... preferable to write an application program require to communicate... in the java.net package. Through TCP we can communicate over the network. Java
Stoting file name in Map
Stoting file name in Map  how to store id and file name in map
Map Java Objects with Database tables
Map Java Objects with Database tables  How to map Java Objects with Database tables?   First write Java domain objects ie. beans with setter and getter methods. Then map java class to table and database columns to Java
Struts logic iterate
:iterate name="listMsg" id="listMsgId" > <bean:write name="listMsgId... iterate <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>...; <body> <h1> Search </h1> <logic:iterate name
Site Map
Site Map We have organized our site map for easy access. You can browser though Site Map to reach the tutorials and information pages. We will be adding the links to our site map as and when new pages are added
<logic:iterate> - Struts
  //Pl help me out Im executing the query here in a separate class and returning the arrayList ArrayList liUserGroup = new ArrayList... is the jsp my PROBLEM IS IAM NOT GETTING THE LIST FROM THE LOGIC ITERATE ?? DID I DID
write the result into excelsheet
= myWorkBook.getSheetAt(0); /** We now need something to iterate through the cells...write the result into excelsheet  package reader; import... an Excel File and Store in a Vector Vector dataHolder=readExcelFile(fileName
Java file read write operation
Java 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
hash map
hash map  write a program in hash map , that shows the value in asending order. but not key value. ex: key value ==== ===== k5 ashutosh k1 babita k7 debasis k2 vikas plz help me
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
Large File reading through Axis2 Web service
Large File reading through Axis2 Web service  This is Vinay Rai. This is regarding the web service help which i am looking for. I am currently... have to write a web service which would read the XML or JSON(format) data which
Reading Text file and storing in map
Reading 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
upload a file and write it in JSP using servlet
upload a file and write it in JSP using servlet  Hello, I'm facing a problem here. I want to upload a file through abc.jsp and write the contents of file using a servlet in xyz.jsp. It is supposed to be a excel file which
Java Write To File From FileInputStream
Java Write To File From FileInputStream In this tutorial you will learn how to write to file from FileInputStream. Write to file from FileInputStream in java... input bytes from a file or can say it reads the streams of bytes. And to write
How to iterate over a checkbox group
How to iterate over a checkbox group  Hi. I am new to using JQuery..." groups. My plan of attack was to iterate over the MASTER checkbox group... resides. I've tried all manner of techniques, including "$.each" and ".map
How to write .properties file from jsp
How to write .properties file from jsp  Hi i new to java i stuck here please help me... my problem is "I wrote a class to write the .properties file... it in my jsp but Iam unble to modify/write the .properties file and Iam not getting
How to copy a file in java
file through FileInputStream and write it into another file through... write the content to target file using out.write() in which starting from 0... a content of one file to another file. In java, File API will not provide any
Java write to file line by line
Java write to file line by line In this section, you will learn how to write a file line by line. It is better to use Writer class instead of OutputStream class if you want to output text to the file since the purpose of Writer classes
Separate column for the navigation tree in AdvancedDataGrid
Separate column for the navigation tree in AdvancedDataGrid : In this example... a separate column. You can set the folderClosedIcon, folderOpenIcon...;s:Panel title="Separate Column for the navigation tree
Writing and reading from/to a serialized file through Hash Table in Java
illustrates you how to read and write from/to a serialized file through the hash table... Writing and reading from/to a serialized file through Hash Table in Java... the the program creates the serialized file otherwise. This program first write
solution of k map in c
solution of k map in c  write a program in c to solve k-map with digital circuit
Show content of .vm file as output using Velocity
Show content of .vm file as output using Velocity  ... content of .vm file using velocity and also shows how to use Iterator...;  1:- Initialize velocity run time engine through method  init(). 2
write to file from servlet - JSP-Servlet
write to file from servlet  Hi, I have a jsp file where I input data and retrive data through servlet. However; when I edit data it is not showing right data on the web site. I am also trying to write this data to file
Write Keys and Values to the Properties file in Java
Write Keys and Values to the Properties file in Java... how to write keys and values in the properties files through the Java program... values and puts into the properties file list through the help of hash table
Collection Iterate Example
Collection Iterate Example       In this section, you will get the detailed explanation about... the hasNext() method through the following java program. True is return
how to modify content of XML file
to xml file to replace "XYZ".Every time with the content of text box the file should...how to modify content of XML file  hi, I want to modify content of a xml file.There are two tags of similar name say <ContentName>C:\Myinfo
Connecting to Unix through Java - JavaMail
Connecting to Unix through Java  Could you please tell a sample code, where i connect to the unix server and run a script and write the results in a file and mail that file back to me
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
Read and write file
Read 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 transfer the excel content on consol to the database
How to transfer the excel content on consol to the database   Hi I have write the java code with which I am able to read the excel file and display its contents on the console but I am unable to transfer the content
Write Text File to Table
Write Text File to Table     ... the records of a simple text file and write (insert) into a simple table in MySQL database. All records are written in the simple text file and again, if you need
Write data in doc file
Write data in doc file  How to write data or string in word file
upload the text file through html and insert those data into the table
upload the text file through html and insert those data into the table ... contains lot of columns.text file also contains lot of data to insert into table.now i want to upload the text file through html and insert those data
run a batch file through javascript
run a batch file through javascript   How to run a batch file through javascript without prompting
Java File content type
Java File content type In this section, you will learn how to get the content type of the specified file. Description of code: This is essential part of the file. In various applications, there is a use of content type. Here we

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.