I/O / Streams :: Java Reading And Output Too Slow

Sep 17, 2014

I have a code below that is reading large image size and writing them to file however the process is too slow. how can i refine this code in such a way that it will work faster?

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;

[code]...

View Replies


ADVERTISEMENT

I/O / Streams :: Java Reading And Output Is Too Slow

Sep 17, 2014

I have a code below that is reading large image size and writing them to file however the process is too slow. how can i refine this code in such a way that it will work faster?

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;

[code]....

View Replies View Related

I/O / Streams :: Continuously Reading Watch Events

Dec 6, 2014

I'm trying to synchronize two folders and their sub directories between a client and a server. I have a modified version of this class which I've posted below. In my Client class, I create a WatchDir object and call its processEvents() method in an infinite loop. The method returns a myTuple object (a struct containing the event type and a path object) if an event is registered and null if not.

The problem is that this only seems to work for the first event to happen in the directory (i.e. if I add a file to the watched folder, my WatchDir object.processEvents() returns one Tuple with an ENTRY_CREATE event and never returns another Tuple for other file additions/deletions/modifications that happen after). I'd like for processEvents to be continuously called (hence the infinite while) returning a Tuple each time some event occurs.

My modified WatchDir:

import static java.nio.file.StandardWatchEventKinds.*;
import static java.nio.file.LinkOption.*;
import java.nio.file.attribute.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;

[Code] ....

View Replies View Related

I/O / Streams :: Reading Up To The First Delimiter And Then Moving On To Next Line?

Mar 22, 2014

I have a text file that has contents as follows:

testing1,true,0,0.0,0,0.0,4.0,0.0,0.0,0.0,0.0
test2,true,0,0.0,0,0.0,4.0,0.0,0.0,0.0,0.0

I am trying to read only the first item in each list using a comma as a delimiter using the following code.

public String[] pList() {
ArrayList<String> names = new ArrayList<String>();
String word;
try {
String path = P_FOLDER + P_FILE;

[Code]....

View Replies View Related

I/O / Streams :: Escaping Double Quotes Be Applied To Reading From A File?

Sep 26, 2014

If I'm using an xml file and the piece of data I want from the file looks like Staff id ="Test";

Is it something like this? Only seen two examples of it but I'm not sure they were reading from a file like myself.

Staff id = """ + Test + """;

View Replies View Related

I/O / Streams :: Reading From And Writing To A File Then Read Again Including Data Written

Oct 11, 2014

I'm having a bit of trouble with using the Scanner and the Printwriter. I start with a file like this (1 = amount of Houses in the file)

1
FOR SALE:
Emmalaan 23
3051JC Rotterdam
7 rooms
buyprice 300000
energylevel C

The user gets (let's say for simplicity) 3 options:

1. Add a House to the file,
2. Get all Houses which fullfil requirements (price, FOR SALE / SOLD etc.) and
3. Close the application.

This is how I start:

Scanner sc = new Scanner (System.in);
while (!endLoop) {
System.out.println("Make a choice);
System.out.println("1) Add House");
System.out.println("2) Show Houses");
System.out.println("3) Exit");
int choice = sc.nextInt();

Then I have a switch for all of the three cases. I keep the scanner open, so Java can get the user input (house = for sale or sold, price = ... etc). If the user chose option 1, and all information needed is inputted and scanned, the House will be written to the file (which looks like what I typed above).

For this, I use try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Makelaar.txt", false)))). This works perfectly (at least so it seems.)

If the user chose option 1, and all requirements are inputted and scanned, the Houses will be read (scanner) from the file and outputted. For this I use the same Scanner sc. This also works perfectly (so it seems atleast).

My problem is as follows: If a House has been added, I can only read the House(s) which were already in the file. Let's say I have added 2 houses, and there were from the start 3 houses. If option 2 is chosen, the first 3 houses will be scanned perfectly. An exception will be caught for the remaining 2 (just added) Houses. How can I solve this? I tried to close the Scanner, and reopening it, but apparently Java doesn't agree with this

View Replies View Related

Java Streaming Project Getting Slow After Hosting

May 20, 2014

I am working on a Java Streaming Networking ( Client Serve ) project , among remote client can:

1 ) chat,

2 ) Share files,

3 ) Share Screen live streaming,

4 ) Access the remote system.

All are working well faster & live on networking. But if i host on the Hosting server the all process are working but in deadly slow streaming is not live..,

View Replies View Related

Reading Text File Output

Mar 16, 2014

I have to write a program that reads the input from a text file!

Beware the Jabberwock, my son,

the jaws that bite, the claws that catch,

Beware the JubJub bird and shun

the frumious bandersnatch.

I should print the number of lines, the longest line, the number of tokens on each line and the length of the longest token on each line.

I was able to find the number of tokes in the line but im having having problems reading the longest word ,, my program gives me the number of letter of each line instead of only the number of letter of the longest word!!

this should be my output:

Line 1 has 5 tokens (longest = 11)
Line 2 has 8 tokens (longest = 6)
Line 3 has 6 tokens (longest = 6)
Line 4 has 3 tokens (longest = 13)

Longest line : the jaws that bite, the claws that catch,

import java.io.*;
import java.util.*;
public class InputStats{
public static void main (String [] args )

[Code] .....

View Replies View Related

I/O / Streams :: Reading A File Line By Line And Deleting It

Oct 15, 2014

If I want to read my file line by line and when it hits a certain value from that point it should start deleting the lines until the tag ends.Just curious will my code actually work at the moment or not because it goes through so many times then goes straight back to the variable declarations at the start of the method and never hits the console print line.

public void removeEnvironment(){
//declare variable to environment id
String environmentID = "Environment id";
String lines = null;
boolean lineFound = false;
boolean end = false;

[code]...

View Replies View Related

Reading Contents Of Several TXT Files - Output File Is Blank

May 4, 2015

In the program below I'm trying to read the contents of several .txt files in the same diretory and create a new .txt file containing all of the data from each file. My output is generated in the console however my .text file is blank.

public static void main(String[] args) throws IOException {
  String target_dir = "C:Files";
  String output = "C:Filesoutput.txt";
  File dir = new File(target_dir);
  File[] files = dir.listFiles();
 
[Code] .....

View Replies View Related

Reading Text File With Specific Input Format - Output Formatted Report

Apr 10, 2014

Here's a link to it : [URL] ....

The basic gist is it's "A program that reads in a text file that uses a specific input format and uses it to produce a formatted report for output."

Specifically :"For this lab you will write a Java program that produces a simple formatted report. The program will prompt the user to enter a file name. This file must contain information in a specific format (detailed below). Each "block" of the file contains information for one player in a competition -- the name of the player followed by a number of different scores that that player achieved. The program should find each player's average score, median score and best and worst scores and display them in a line on the final summary report. The program should also determine which player has the highest average score and which player has the lowest average score."

I get the following errors when I try and compile it:

Enter an input file name: Project11.txt
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException... -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at Project11.getMedian(Project11.java:68)
at Project11.main(Project11.java:27)

I get that the error(s) reside in lines 68 and 27, among problem other areas, but I'm not exactly sure how I can fix them.

Here's my code:

import java.io.*;
import java.util.*;
public class Project11 {
public static void main(String[] args) throws IOException{
Scanner in = new Scanner(System.in);
System.out.print("Enter an input file name: ");
String input = in.nextLine();

[Code] ....

View Replies View Related

I/O / Streams :: Java Streaming Big String

Aug 27, 2014

I have a very big string that I am returning from servlet to javascript. I am using PrintWriter.

PrintWriter out = response.getWriter();
out.print(bigString);

But as the string is very big my code is not working. My browser just hangs.

Also is it possible to stream the output? i.e instead of sending entire string, can I send small part of string at a time. So that my browser will not hang. I don't want to handle streaming manually I am just looking for an IO class which will do the streaming automatically.

View Replies View Related

I/O / Streams :: Deserializing Visual Basic 6 Files In Java?

Jan 27, 2012

I have to be able to read files that have been serialized in VB. 2 things, 1 they are serialized in Binary, and I tried to look up on how to serialize/deserialize in Binary, but didn't have much support...

Also in the VB code they talk about "TYPES" which seems to be to just be a class full of stuff...

View Replies View Related

I/O Streams :: Read Certificate In Token Usb - Utilizing Java?

Oct 14, 2014

I am developing a program that reads a digital certificate in a USB token, but can not cause the program to access the token.

View Replies View Related

I/O / Streams :: How To Parse CSV Using Runtime Configurable Bean Class In Java

Oct 30, 2014

I will detailedly explain my requirement below,. I am going to automate a manual process. I will be reading multiple CSV files from a remote location using java.There are five formats of input files are expected, each differs in their header structure. For example, Type 1 - Number, ID, Name, Phone, Address...Type 2 - Number, GID, Employee Name, Address1, Address2, Phone number and so the other three types are also differs.

The precondition is not all the files are expected for a particular run. I need to read these files one by one, validate it, log the validation error and i have to consolidate all the correct data from all the files together in a standard output format, in a single file The standard output format will be like,Number, Name, ID, Address

I need to have the above data alone in the output file and rest of the data can be ignored.What i have tried is as follows, I have created 5 bean classes representing each type's header. I just read an input, identify its type and parsed it. I parsed line by line.

public String[] parseCSV(String inputLine){
try {
String[] fields;

Pattern p =
Pattern.compile(",(?=([^"]*"[^"]*")*(?![^"]*"))");
fields = p.split(inputLine);
/*for ( int i = 0; i < fields.length; i++ ) {
System.out.println(fields[i]);
}*/

[code]...

I have validated as per the validation rules and i appended each line elements into an object. I have added all the objects in to a MAP collection. Likewise, i have created 5 beans and did the same.But, what is the change needed now is,. All the headers in all the five types of rosters are configurable items. hence, i have to change my bean classes everytime when the header structures are changed.

We have to create one single utility, which is configurable for all the five types of input files. To be very clear, if type 1 input comes with 8 columns and type 3 comes with 12 columns, the utility is able to parse it.

We are going to have a table which has the data regarding the header structure of all the five types of inputs alone. Once i read a file and identify its type, i will hit the database and read the header structure of that particular type and its column count. I will match the column count with the input file's header count and i will have to proceed creating a bean class on runtime depending upon the header structure read now. I will validate and consolidate as i did above. The requirement is, Runtime configuration of bean class, depending upon the type of input.

View Replies View Related

Applets :: Loading Is Too Slow

Jan 31, 2014

We are using an applet in our web application. The applet of our application is dependent on bouncycastle jar,bcprov-jdk15.jar and few other jar's whose size comes around 4 mb. When using the appliaction on jre7, the applet is taking too long time to load than usual time. Is there any way to place these jar's in client machine? Will it improve the performance? Is there any other way to reduce the loading time of applet apart from placing jars in client machine?

View Replies View Related

X3D File Parser Is Way Too Slow

Nov 9, 2014

I've recently tried to write a file parser for the .x3d file type as it's one of the few 3d model types I can find written in easy to understand (and interpret) English. While it technically does work (or what I have so far), the issue is that it takes far too long (17 minutes) to parse just a part of the file (the vertices of the model).This is the code for the object itself:

import java.io.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class ModelLoader {
BranchGroup object = new BranchGroup();
BufferedReader reader;
String line = "start";

[code]....

Anyway, here are some observations I've made about the file:

-The line in the file itself that contains all the vertices is all one giant string according to the file.
-There are apparently 18,000 vertices in all (according to the command at line 18).
-Unless Netbeans automatically terminates infinite loops after a certain amount of time, it is most definitely NOT an infinite loop as I have seen the program terminate on its own (after 17 minutes, though).

I had a theory that maybe organizing each vertex into its own line and then having the program switch to the next line when it's done reading that vertex might make the program run faster, but I'm not sure why it would, so I thought I'd come here in case that theory turned out to be a dead end.

View Replies View Related

Class Is Moving Extremely Slow

Dec 8, 2014

I'm currently taking a computer science class but the class is moving extremely slow and I'm not learning much, so I've started to program on my own. The most recent project I've done is a tic tac toe game, and I'm looking for something else to do now. I can do with an increased difficulty from this project, but not extremely difficult.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;

[code]...

View Replies View Related

EJB / EE :: Deploy Slow Using 3.1 And JPA In Rational Application Developer?

May 13, 2014

I have a large scale enterprise application (5 modules) project using RAD, WAS v7, Java EE 6 (EJB 3.1, JPA), ZK framework.

The project is using RAD as IDE. The problem is that it takes too long to deploy (more than 5 min) when changes are made to the EJB's (although the changes are minor in only one file) but when changes are made to zk framework (the web & presentation layer), it is fast to deploy.

Don't know what cause the problem. Is it because of EJB 3.1/ JPA or RAD/ WAS?

Is it happening in other IDE or applcation server also?

View Replies View Related

JavaFX 2.0 :: Slow GUI Response When First Displaying Controls

Jun 15, 2015

I have been using JavaFX for some time now and have encountered many performance issues, mainly with the initial display of GUI elements.  For example, a simple stage with a table view (with about 10 columns) and chart takes about 5 seconds to display.  A color picker will take about 3 seconds from the time I click the control to when it displays the pallet.  This only happens when the controls are first displayed.  This can't be right.  I have searched and none seems to have a similar problem so I thought I would ask here just to make sure.  Here is a sample Hello world that shows the problem with the color picker (takes ~ 3 seconds to show pallet when clicked). 
 
public class HelloWorld extends Application
{
    @Override
    public void start(Stage primaryStage) {
        StackPane root = new StackPane();
        ColorPicker cp = new ColorPicker();
        root.getChildren().add(cp);

[Code] .....

View Replies View Related

JavaFX 2.0 :: Slow Performance On Linux For Visual Effects

Mar 6, 2015

Visual effects such as Transitions perform very poor on linux "wheezy" compared to windows. I noticed this on different PC's, checked for Java7 and Java8. If the UI contains many objects then the transition sometimes does not even appear.
 
I do not think this is graphic card related since videos play quite ok.
 
I use the default ATI driver without Xorg.conf file and  installed the xcompmgr
 
and tried several options, such as
 
Option "Composite" "Enable"
or
Option        "backingstore" "true"   
Option        "AllowGLXWithComposite" "true"
 
This did not speed up things, are there other things that I could do to improve the performance ?

View Replies View Related

Networking :: Socket Creation Too Slow Versus URLConnection

Oct 27, 2014

I'm trying to write a transparent proxy like polipo. Polipo is written in C and I want to have the same result in java.
 
A simple program that can filter/monitor all connections created and closed by the browser.
 
To do so, I've chosen to work with sockets, because that's the only way i know to read and write raw data to and from the browser in a completely transparent way.
 
In this moment my code reads and writes every couple of request/response but I've noticed profiling it that the time needed to create the socket is a bottleneck.

Using URLConnection to create the same connection I need much less time than sockets.
 
When socket creation implies 50ms URLConnection implies only 1ms.

View Replies View Related

Servlets :: Fetch Data From Backend (DB2) And Export To Excel - Slow File Download

Jan 31, 2014

Recently we got an issue about file download. We are using below code to fetch the data from backend(DB2) and export to excel.

Before Jan 15 it use to take 2 minutes to download the file (2 MB size). But now its taking half an hour to download.

response.setContentType("application/vnd.ms-excel");
response.setHeader("content-disposition","attachment; filename=Attendance_Report.xls");

We have restarted server, system but still problem exists. We found that there is no code level or data base level or network level issues.

Now we have to see server level issue. What are the factors which effects the file downloading at server level.
We are using websphere 6.1 ,java1.4

View Replies View Related

Reading PDF By Using Java

Feb 5, 2014

i am reading pdf through java and write that data in .csv file.problem is like that when i read 500 pages from pdf at that time they can write only 496 lines what can i do for that i can read all 500 pages from the pdf .my code is like..............

public class pdf1 {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
try {
PdfReader reader = new PdfReader("me1.pdf");

//int n = reader.getNumberOfPages();
File outFile = new File("b.csv");
int n=500;
int count=0;
BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));

[code]....

View Replies View Related

Java File Reading

Sep 22, 2014

Im trying to read a file called m1 and put that information into a 2-D array with the first two numbers being the size of the array i was able to set the size of the array but how do i populate array?

import java.util.Scanner;
import java.io.*;
public class test{
public static void main(String [] args)throws IOException{
Scanner fr = new Scanner(new File("m1.txt"));
String line = fr.nextLine();

[code]....

View Replies View Related

I/O / Streams :: How To Write A File Into Unix Folder From Windows Folder Using Java

Oct 30, 2014

I need to copy a file from Windows folder to unix folder using Java

I need a FTP utility.

The file is processed by a Java program and the file has to be written to Unix folder

I have the unix server name and folder name.

how to do it?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved