Tinashe
BAN USER
/**
*Most of the code copied from howtodoinjava dot com site
*
*/
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class MemoryMappedFileReadExample
{
private static String largeCSV = "data3GB.csv";
public static void main(String[] args) throws Exception
{
//Create file object
File file = new File(largeCSV);
//Get file channel in readonly mode
FileChannel fileChannel = new RandomAccessFile(file, "r").getChannel();
//Get direct byte buffer access using channel.map() operation
MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size());
// the buffer now reads the file as if it were loaded in memory.
System.out.println(buffer.isLoaded()); //prints false
System.out.println(buffer.capacity()); //Get the size based on content size of file
//You can read the file from this buffer the way you like.
for (int i = 0; i < buffer.limit(); i++)
{
processYourDataIntoDatabase((char) buffer.get());//here do whatever you like in DB
}
}
}
iteration through the array actually starts at i=1,but since one may like to see the other differences between elements,I am starting from 0.
#include <iostream>
using namespace std;
void find_max(int arr [], int arr_len){
int max = arr[1] - arr[0];
for(int i = 0; i < arr_len - 1; i++ ){
//cout<< arr[i+1] - arr[i]<<" ";
if(max < arr[i+1] - arr[i]){
max = arr[i+1] - arr[i];
}
}
cout<<endl<<max<<endl;
return;
}
int main(){
int arr[] = { 0,6,14,19,20,60,61,70,85,95,100};
find_max(arr,11);
return 0;
}
- Tinashe February 12, 2015
RepOffers ammunition for sale form top brands
RepSpent high school summers donating toy monkeys in Minneapolis, MN. At the moment I'm building glue in Edison, NJ ...
Repjesusitahyer, Data Engineer at ASAPInfosystemsPvtLtd
Hello Everyone, I am Jesusita and I am passionate about writing the stories about powerful mantra to get what you ...
Repamandaben422, Graphics Programmer at Abs india pvt. ltd.
Hi, I am a webmaster from the USA. I think social networks have the power to connect two different people ...
Repdavisjerryh, Backend Developer at Abs india pvt. ltd.
For the last two years, I am Effectively managing the team’s performance, conducting regular performance reviews and appraisals, and ...
Repjuanktait, Blockchain Developer at ADP
I am Juan from Seattle, WA. I am working as a LAN administrator. I love music, reading historical books, and ...
Repbarrietrosado, abc at ABC TECH SUPPORT
Hi, I am Barrie, from Ualapue USA. I believe that every challenge has a solution - and I take great satisfaction ...
RepSoccer lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
RepSherriMooney, Network Engineer at Arista Networks
I am not a model but as a photographer, I can't see how one could call it fun. Matter ...
Repthubmorfin, Android Engineer at ABC TECH SUPPORT
I am currently working as a safety-focused Service Technician from Red Bank. I execute routine maintenance work while advising clients ...
From my understanding, a dictionary is a set of words, lexically sorted, providing a meaning to the given key/entry in it.
- Tinashe August 08, 2016In your case, do you have a list of the "words" and their meanings/values/whatever and need the dictionary for random access of any of the available words?
If that could be the case, I would suggest a hashMap as underlying data structure where key is the word itself.