deutsche bank Interview Question for Dev Leads


Country: India
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use memory-mapped files to read big files which cannot fit into RAM.

- Vit July 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
 
public class ScannerExample 
{
    public static void main(String[] args) throws FileNotFoundException 
    {
        //Get scanner instance
        Scanner scanner = new Scanner(new File("SampleCSVFile.csv"));
         
        //Set the delimiter used in file
        scanner.useDelimiter(",");
         
        //Get all tokens and store them in some data structure
        //I am just printing them
        while (scanner.hasNext()) 
        {
            System.out.print(scanner.next() + "|");
        }
         
        //Do not forget to close the scanner  
        scanner.close();
    }

}

- Anonymous August 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/**
*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
        }
    }
}

- Tinashe August 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Is it better than using Scanner (as used in other answer) ? What are advantages/disadvantages ?

- undefined October 31, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use MappedByteBuffer in that case. It will work even after program get crash.

- Anonymous August 11, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

USe MappedByteBuffer

- Kulbhusha.n August 11, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More