ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tusharnakra <tusharna...@hotmail.com>
Subject How to load cache when reading data from txt files
Date Tue, 29 Mar 2016 22:37:03 GMT
Hi,

I created a file helloworld.txt. Now I'm reading from the file and then I
want to load the contents of the file into the cache, and whenever the cache
is updated, it should write to the file as well.

This is my code so far:

Please tell me what to do to load the cache and then write from the cache to
the file, as the instructions are not clear from your documentation.

(Also, I have clicked on the subscribe button so many times but I haven't
got any confirmation email in the past 24 hours)

package apache.ignite.schemas;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

public class File {

        public static void main(String[] args) {
               
                FileRead();
                FileWrite();
        }
               
                public static void FileRead()
                {
                try {
                 BufferedReader in = new BufferedReader
                 (new FileReader("/Desktop/helloworld.txt"));
                 String str;
                 while ((str = in.readLine()) != null) {
                    System.out.println(str);
                 }
                 System.out.println(str);
                 }
                 catch (IOException e) {
                 }
              }
               
                public static void FileWrite() {
                        try {
                           
Files.write(Paths.get("/Desktop/helloworld.txt"), "Hello World".getBytes(),
StandardOpenOption.APPEND);
                        }catch (IOException e) {
                            //exception handling left as an exercise for the
reader
                        }
                }
        }



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-load-cache-when-reading-data-from-txt-files-tp3750.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message