Jesse Kelm

Greenhorn
+ Follow
since Sep 06, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jesse Kelm

This worked out perfectly and without the delay that Bill described.

What I ended up doing was passing the ArrayList of file names to the print routine, thus the pageIndex had the correct amount of pages required. I then loaded each file into a BufferedImage, ran that through the RenderedImage process and everything is working correctly.

Thanks very much to Bill and Martin!!!

Jesse
11 years ago
I tried to do exactly that in the method, but when it runs, the pageIndex variable is automatically set somewhere and is used extensively. It is reading how many pages is sent to it from the collection and loops through it. It it only has the first rendered image, it treats the pageIndex as 1 and provides an out of index error message.

I am still trying to resolve this if you have any other suggestions or can suggest a way to do exactly this.


public int print(Graphics g, PageFormat f, int pageIndex)
11 years ago
Thanks Bill..I will give that a shot. You couldn't find any way to send the images one by one through the print routine either instead of loading them all into an arraylist first?

Martin..

That is ideally what I am trying to do, I just can't seem to determine how to print the multiple images one by one in the same print job. It doesn't appear that Java lets you do that. You have to supply the print routine all of the image data up front for it to work through all of the objects.
11 years ago
I am trying to take a list of .png files in a directory and print them all in the same print job. I am able to do this correctly for jobs that have around 80 pages in them by loading each image into a BufferedImage and placing them into an ArrayList, and then sending the ArrayList to the print method I will paste below. The problem is when there are more then 80 pages, when trying to load all of the images into this ArrayList, we start to receive Out Of Memory errors due to the amount of memory the images take up when loading them. Does anyone have any suggestions on a better way to do this? Thanks in advance!!

Here is the code that loads the images into an ArrayList and provides out of memory error messages once we load too many .png files in to the images ArrayList



Here is the print method:

11 years ago
Thanks much for the help John! That is exactly where the issue was, not sure how I overlooked that one.

Also thanks for the syntax help Campbell!
12 years ago
I am trying to figure out how to force a user to input some sort of data at a continue prompt. So if they just press the enter key, it will tell them the entry is required. Here is what I have. It works if they press y or n and gives the error the entry must be y or n if they use a different letter. The code seems to wait after the enter key is pressed with no values. Here is my code:

12 years ago
Nm...I found out this won't work with MS Access. That is the issue.
Thanks Everyone!
I am attempting to load data from a .txt file that is csv formatted into a MS Access Database. I tried doing this with the INSERT statemetnt with success, but the processing is very slow. When searching on how to speed it up, it was suggested that using LOAD DATA INFILE was much quicker. When attempting to do this I receive an error of an invalid SQL statement. Here is my code and error message:



java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown Source)
at ConnectDatabase.main(ConnectDatabase.java:41)


Thanks in advanced for any insight as to what might be wrong.


The more I look at it, I don't think the program is terminating, but not recognizing the compare of ch == '['. When outputting the value of ch to the screen, it is correct. Do you need to do a different sort of compare for reserved characters like [ and =?
12 years ago
Sorry bout that...I don't get any messages, it just terminates. I am using a class named TextIO by David Eck for the input, output. I am sure there is a much better was of doing this, but again I am just learning. Everything works fine if I remove the comparing of the [ sign. Here is the code but I can't attach the .java class file:

public class Report {
public static void main(String[] args) {

String input = "";
String requestNumber = "";

TextIO.readFile("d:\\reports\\test.tmp");

while (!TextIO.eof()) {
input = TextIO.getlnString();
char ch;
int i;
input = (input.toUpperCase());

for (i = 0; i < input.length(); i++) {
ch = input.charAt(i);
if (ch == '[' ) { This line creates the issue:
if (ch >= '0' && ch <= '9') {
requestNumber = requestNumber + input.charAt(i);
}
}
}


}
}
}
12 years ago
Obviously a beginner and can't seem to find an answer to my question so here goes:

I am importing data from a file line by line and need to test for the [ character and the = character, but when I try, Java terminates. The data is already stored as a String named input and the input looks like [20110906123456]. Here is what my code looks like:



Later on I will need to do the same sort of test with the = sign...

Thanks in advance for any assistance you can provide!!

12 years ago