How to show huge data - java

I am having very huge data. That I want to show in browser (Web app), But while loading browser is crashing.
Basically Its a grid that has row and column header and rest of the grid is having check boxes, that user will click based on row and column header values.
when I am loading this data its going up to 2gb and total data will be 5gb. any one can help me how can I show this much data in browser or in any type of app(windows or web app) or any type of technology.

Please try the pagination technique to show the data in part.
So it will reduce the load on page but will increase the database hit.

One class that may help you is the GZIPInputStream and GZIPOutputStream. It sounds like you're using text data so compressing what you're sending should drastically cut down the amount of data that the client has to download.

Related

How I can create history layout in android studio such as recent

I am building an app include edit text and button. The user can put text in the edit text, then click button to transfer him to the browser.
So, I would like to create other layout as recent to store the text that the user entered on the edit text.
How I can do that? I need the logic or code that can help me!
Also, should I have create database to store the data?
Example:
enter image description here
You can store data in multiple ways, and you will need to understand what is right for your use case. You can store data in memory, by simply creating a List with your data type and adding to it every time user will click a button, but then it will not persist between sessions with the app.
If you want the data to persist, then you would need to use permanent storage, and there are a lot of options here:
You could use Shared Preferences
You could use File System and save the data to a file
You could use a database i.e SQLite, and store data there
You could use external server, and get the data through REST API.
Generally, there is a good overview of data storage in Android in the documentation which also have code examples.
Every option comes in multiple ways to accomplish it. There are built-in solutions, and multiple libraries to help you with this task, but first of all, you will need to understand what is the predicted usage of this data. I.E Should user have access to the data from another device? Should the data be available offline? Will data have complex structure? How the app can expand in the future? e.t.c.
Only by knowing this you can design how you will handle it.
If you need logic or code to create view, then you will need ListView, or RecyclerView, Adapter for handling the data, extra xml layout file for single item of your data.

Split a long text for paginated display

I'm building a website for a friend who's writing a novel, and want to display it, chapter by chapter, in a book-like display, with pages turning.
I have a frontend app in Angular 2 and a backend in Java (as they're the tools I'm more familiar with). A backoffice on the Angular app allows the user to add the text of a chapter, which is sent to the backend to be stored in the DB. Then the front of the Angular calls the backend to retrieve the chapter, and has to display it in the book-like display.
My problem is how can I split the text of the chapter into pages in order to display it. I could change the backoffice to force the user to add the text page by page. I could ask the user to put a specific marker in the text to indicate a page break. But I'ld like the process to be as transparent as possible for the user.
So I went for a solution by splitting the text on the backend. I estimated how many characters are on a line, and how many lines are on a page, then I cut the text accordingly (with some adjustments, as it's a HTML text with tags in it).
But it feels like a very strict approach, as I'm choosing the size of a page, regardless of the display interface size.
So I'm wondering if there is a better approach :
- a different splitting algorithm
- a tool front-side to display my text without splitting it
- something else
Does anyone had to face a similar problem ?
Thanks
You are performing that action on server side that has no sense of the page length.
I assume that a better approach shall be to get the complete chapter from backend to front end; and have a front end function that will calculate :
- the number of characters per lines based on page size
- the number for line based on page size
- the number of chapter pages based on previous info
This is a way better approach than your full backend ones.
However; this is not a responsive approach.
Do you have interest and need within a responsive one ?
If yes; you may add a watch on the page length/height to recalculate the above values and re generated your pages

Parse dynamically loading (by scroll) page using JSOUP

I am trying to count number of apps for a specific string. Like Flash Light, and here is the link that i am using to load page in jsoup,
Jsoup.connect("https://play.google.com/store/search?q=Flash+Light&c=apps&gl=us&hl=en")
Problem is that it only return 20 apps but there are more than 100 apps results when i open it in browser and scroll down. When i monitored closely i found out that for first time PalyStore shows 20 results rest of the results are fetched on scrolling.
Can anyone please tell me how to handle that?
Also i just want to count number of results if there is any other way that would be great too.
Jsoup cannot process dynamically loaded content. You need a different set of tools, like htmlunit.

Display fast changing values in the browser

I have written a Java program, which reads numbers from different files. The numbers are added while being read from the files and the sum is displayed in a browser. The browser keeps on displaying the new sum getting created at every step.
I know how to display static values in a browser. I can use Javascripts. But I don't know what mechanism to use to display continuously a changing value.
Any help is appreciated!
You'll have to request the data to display from the server. You can use a data-binding library like Knockout to automatically update the page as the underlying model changes, or you can just use a library like jquery to modify the DOM on your own.
Alternatively, you could keep a pipe open to the server using the Comet model: http://en.wikipedia.org/wiki/Comet_%28programming%29. However, it can be expensive to eat up a thread for long periods of time on your web server.
Good luck.
Check out knockout.js http://www.knockoutjs.com/ it is a framework for updating UI automatically when data changes

Component for displaing (>25MB) text file in FLEX

Flex front-end using AMF to Java back.
Trying to read, in real-time, a file that is being written to. For example, a log.
I'm using Java's RandomAccessFile class to read the "new" lines of the file and send them back to the UI as a byte array along with the byte offset to start reading from next time.
Using an mx:List to display all lines of the text file.
The problem I'm running into, is Flex, or Flash Player, running out of memory on mildly large files, >25MB.
Is there any preferred method of displaying large amounts of text data in Flex that I'm missing? Or does Flex/Flash just handle this poorly and I'm basically screwed?
Thanks.
If 25MB is only mildly large then I'd say you probably need to page the data into the component, and simple store just a couple of pages in memory at a time. I'd probably pick something like TextArea over List, but creating seamless scrolling for a TextArea could be difficult if you don't have all the data which sounds like what you'll have to do. So stick with List for now, and figure out how many lines you want to make a page. And implement your backend as a method like:
// service call interface
public Page getPage( int lineStart, int lines );
// response object from the service call
public class Page {
private var _totalLines:int;
private var _lineStart:int;
private var _lineEnd:int;
[ArrayElementType("String")]
private lines:ArrayCollection;
}
Then you can load a page and store X number of pages in memory, but use the totalLines in the file to know how big your model is so the scrollbar can render properly. You'll just need to build a paging dataprovider that loads pages not yet loaded, and ditches pages if they aren't displayed or pages that are furthest from what's being displayed.
Right now I'm working on component that will be able to show up to 100Mb of text fast. You can just replace your mx:TextArea with LongTextArea:
<longText:LongTextArea text="{...}"/>
Download LongTextArea SWC.

Categories

Resources