Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


mahindar
iterate through map and write the content in a separate file
0 Answer(s)      2 years 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);

}

}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
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
Advertisements
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 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 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
Stoting file name in Map
Stoting file name in Map  how to store id and file name in map
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
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
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
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
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
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java... will be able to use OutputStreamWriter on a FileOutputStream classes to write data to a file from Java program. To write the Java Write To File we will use two
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
Write data in doc file
Write data in doc file  How to write data or string in word 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
How to write in File in Java
How 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
Java write to file
Java 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
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
run a batch file through javascript
run a batch file through javascript   How to run a batch file through javascript without prompting
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
Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button
map
map  using map, i want display message based on id selected [both are strings]   i do no   Hi Friend, Try the following code...) { Map map=new HashMap(); map.put("Message1","Hello
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
read from file and store using hash map
read from file and store using hash map  I was stuck with a java project where I have to read a file with two different concepts and store them differently in hashmap. My data file would be something like Adults: Name, xyz
Map words to line number in text file and show occurence
Map words to line number in text file and show occurence  hi i want to Map words to line number in text file and show occurrence of word in java coding
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
write aprogram which shows the use of hashset and iterator (through enter the value through keyboard )
write aprogram which shows the use of hashset and iterator (through enter the value through keyboard )  write aprogram which shows the use of hashset and iterator (through enter the value through keyboard
need to update key , value pair in map from properties file
need to update key , value pair in map from properties file  I have a map with key , value pair. with key as integer and value as string datatype. I want the keys and values to be dynamically updated into map. that is i have
write a program to create an vector and listeterator.and value should be enter through keyboard.
write a program to create an vector and listeterator.and value should be enter through keyboard.  write a program to create an vector and listeterator.and value should be enter through keyboard
write a program to create an vector and listeterator.and value should be enter through keyboard.
write a program to create an vector and listeterator.and value should be enter through keyboard.  write a program to create an vector and listeterator.and value should be enter through keyboard
write a program to create an arraylist and listeterator.and value should be enter through keyboard.
write a program to create an arraylist and listeterator.and value should be enter through keyboard.  write a program to create an arraylist and listeterator.and value should be enter through keyboard
write a program to create an vector and listeterator.and value should be enter through keyboard.
write a program to create an vector and listeterator.and value should be enter through keyboard.  write a program to create an vector and listeterator.and value should be enter through keyboard
write a program to create an arraylist and listeterator.and value should be enter through keyboard.
write a program to create an arraylist and listeterator.and value should be enter through keyboard.  write a program to create an arraylist and listeterator.and value should be enter through keyboard
Storing content from file path to an array
Storing content from file path to an array  Hi, I have a path... would like to access the "Animation.txt" file from this path and store the contents in this text file to an array. I am using jsp. I can access my path but how
How to write into CSV file in Java
How 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
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
how to write file from FileInputStream
how 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 using FileOutputStream
How 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 at the end of the line
how 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
how to display the excel file content in the jsp
how to display the excel file content in the jsp  How to present the content of the newly created excel file in the following jsp to the web browser: print("code sample"); <%@ page import="java.io.InputStream" %>
Java Write To File By Line
Java 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
How to Write To File BufferedWriter in Java
How 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 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
how to write append file in Java
how 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
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 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
 

 

 

DMCA.com