Converting int to string, adding to string then pointing to an url
So I'm getting a null pointer exception here's a snippet of my code (theres plus signs on both sides of the a in my code):
private Image[] tiles;
public Map() {
for(int a=0; a<9; a++){
ImageIcon aa = new ImageIcon(this.getClass().getResource("mapsquares"+a+".png"));
tiles[a] = aa.getImage();
I've also tried:
private Image[] tiles;
public Map() {
for(int a=0; a<9; a++){
ImageIcon aa = new ImageIcon(this.getClass().getResource("mapsquares$s.png", String.valueOf(a)));
tiles[a] = aa.getImage();
whats wrong with either of these?
Edited by: Wub on Feb 28, 2013 3:17 PM
1.) You should use code tags when posting code.
2.) You should read the stacktrace closely to find out which exact line number in your code threw the exception.
My guess is that it's the line tiles[a] = aa.getImage(); because you didn't initialize the array tiles using the new operator. This is just a guess since you didn't post the full stacktrace. Also, NullpointerExceptions are one of the easiest to debug. Just adding print out lines at strategic values can show you which variables are initialized and which ones are not.
Similar Messages
-
Converting from spreadshet string to array and then back to spreadsheet string
My questions is; why is the Spreadsheet string to array function creating more data than the original string had when you change the array back into a spreadsheet string. Im trying to analyze a comma delimited file using array functions since my column and row size is constant, but my data varies. Thus my reason for not using string parsing functions which would get more involved and difficult. So, however, after i convert to a 2D array of data from the comma delimited file I read from, and then I convert back to string using the Array to Spreadsheet String, I get added columns to the file, which prevents another program from receiving these files. Also, the data which I am reading is not all contiguous, it has gaps in some places for empty data. Looking at the file compared to the original after it has gone from string to array and then back to string again, looks almost identical except for the file size which got larger by 400 bytes and where the original file has empty spaces, the new file has a lot of commas added. Any idea?
CharlesThe result you get is normal when the spreadsheet string contains rows of uneven length. Since the array rows have the same number of elements, nil values are added during the coonversion. And of course, the back to string conversion keep those added values in the string, with the associated commas.
example : 3 x 3 array
1,2,3
4
5,6,7
is converted into
1 2 3
4 0 0
5 6 7
then back to
1,2,3
4,0,0
5,6,7
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left... -
Can u tell me how to convert int value in to string
hi to all, can u tell me how to convert int value in to string.
hi to all, can u tell me how to convert int value in
to string.Even this way:
int number = 155;
String mystring = ""+155;
[\code] -
Converting a Labview time into a string with Measurement Studio C++
In my Measurement Studio-based C++ application, I'll be sent a Labview
time in the format of a double, which I believe is seconds since 1904.
Does Measurement Studio for Visual C++ contain a function that will
convert that time value into a string format? I'd like to end up with
something like "hh:mm:ss:msec". I'm basically looking for the
equivalent of the Labview vi, "Format Time/Date String". If Measurement
Studio doesn't provide this, is there some other (hopefully simple) way
to do this?
I can request that the Labview application send me time in a string
format as well as a double; this will require several changes to the
Labview application sending the timestamp, but if that is a simpler
solution that's the option we'll take.
Thanks in advance,
AdamMeasurement Studio does not have a function for this, but you can do
this yourself by first converting from LV epoch (1/1/1904) to Unix
epoch(1/1/1970) and then using c runtime time functions
UNIXEpochOffset is the difference between the 2 epochs at GMT. To
convert to a UNIX system clock value, just subtract the sum of this
number and your time zone offset in seconds
lvTime is the value returned by LV timestamp
#define UNIXEpochOffset 2082844800
int _tmain(int argc, _TCHAR* argv[])
__int64 lvTime = 3214396284; //10:48:13.173 AM 11/9/2005
//GMT offset for Central Time is -6 (3600 seconds). You will need to account for daylight savings time.
int offset = -3600;
time_t unixTime = lvTime - UNIXEpochOffset - offset;
struct tm *newtime = localtime(&unixTime);
printf(asctime( newtime )); //prints out the time in a string format.
return 0;
Bilal Durrani
NI -
How can I convert the variable expression stored as string back to variable expression
How can I convert the variable expression stored as string back to variable expression?
I am storing the expression enterd in the TSExpresssionEditControl as simple string and want to convert back to expression since I want to get the data type of that expression.pritam,
I'm not sure what you're trying to do exactly. If you are trying to get the value of a variable and you only have the name of value in a string, then you can use Evaluate() to get its value. If you want the data type, my advise is to use the GetPropertyObject() API method and just pass in the loop up string. Then you'll have a handle to the data object and then proceed from there.
Regards,
Song D
Application Engineer
National Instrument
Regards,
Song Du
Systems Software
National Instruments R&D -
How to convert a text file content to String in JSP?
Hi,
I need to read the content of a text file and convert it into String and display it on to a JSP file.
But the codings below don't work. Please advise me on how can i display the text file content.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File adCheck = new File("list.txt");
fis = new FileInputStream(adCheck);
int Length = adCheck.length();
byte arr[] = new byte[Length];
int dataRead = 0;
int totalData = 0;
while(totalData <Length)
dataRead = fis.read(arr,totalData,Length);
totalData += dataRead;
String Content = new String(arr);//byte array converted to String
arr = null;InputStreamReader in=new InputStreamReader(fis);
StringWriter out=new StringWriter();
char[] buffer=new char[8192];
int sizeRead;
while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
out.write(buffer, 0, sizeRead);
String content=out.toString(); -
Strings adding zero's to arrays
I have a program that arranges 4 arrays which consist of columns of 10
data points from each iteration of the program. The final program puts
these sets of 10 pts into one long column. I converted the array into a
spreadsheet string. I used the match pattern to find and replace the new
line characters and returns with tabs. Each column has 10 data
points, then one zero separating them from the next 10 points. I've
tried the same idea using backspace, form feed, space characters, etc,
and I still have one row of zeros separating my data points. Does
anyone have any idea what this character could be or how to fix this? I
tried all of the characters in the manuals and none will get rid of this
problem.
Heather
Sent vi
a Deja.com http://www.deja.com/
Before you buy.The poster who suggested the "zeroes" could be squares- signifying a
non-printable character, may be on the right track.
However, it occurs to me that you're using quite an unwieldy way of tackling
a simple problem- and that the way you're using is unnecessarily platform
dependent and complicated by the need to handle a return and a linefeed.
I'm not quite sure how your arrays are arranged- as four discreet arrays?
If it's four separate arrays with 10 points and you want one big array, you
can use the "build array" function. If you pop up the right mouse button
menu over this, you see an option to change an input from an element to an
array. If you make a "build array" with four array inputs, what you get out
is one long 1D array with the four sets of data appended one after the
other. If you then want the output as one long column, a useful trick is to
feed your new array into another "build array" node, this time with only a
single "element" input. This promotes the 1D array to a single column 2D
array, that you can then feed through a "transpose 2D array" and then into a
"build spreadsheet string" to generate your output string without having to
do all the search and replace operations. You may or may not need the
"transpose 2D array", depending on how the file turns out- I tend to simply
do things like this without thinking them through and then tweak them to
make them work- which I find quicker than going through all the details in
advance.
wrote in message news:[email protected]...
> I have a program that arranges 4 arrays which consist of columns of 10
> data points from each iteration of the program. The final program puts
> these sets of 10 pts into one long column. I converted the array into a
> spreadsheet string. I used the match pattern to find and replace the new
> line characters and returns with tabs. Each column has 10 data
> points, then one zero separating them from the next 10 points. I've
> tried the same idea using backspace, form feed, space characters, etc,
> and I still have one row of zeros separating my data points. Does
> anyone have any idea what this character could be or how to fix this? I
> tried all of the characters in the manuals and none will get rid of this
> problem.
>
> Heather
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy. -
Converting numerous strings to one string - any ideas how to do this?
Hi,
I've written a test main class where the user inputs, via the keyboard, one integer value and four strings. I've already converted the one integer to a string value, but I now need to convert all of the strings to one string
Does anybody know how to achieve this?
Many thanks!!Thanks for the reply.
How do I change the saveTo method so it will add commas to the String filmDetails in the constructor within the class Title?
I don't understand what you mean when you say that I write to one file and read back from another. In my main class I'm only reading and writing to one file, as follows,
import simplejava.*;
import videos.*;
import java.io.*;
public class AddTitle {
public static void main(String[] args) {
String film, actor1, actor2, director, title;
int codeNum;
SimpleReader keyboard = new SimpleReader();
SimpleWriter screen = new SimpleWriter();
SimpleReader inFile = new SimpleReader("title_test.txt");
//title = inFile.readLine();
//String[] myStrings = title.split(",");
TitleList titles = new TitleList(inFile);
codeNum = keyboard.readInt("Title Code for the Film");
int intValue = codeNum;
String stringValue = Integer.toString(intValue);
film = keyboard.readLine("Film Title?");
actor1 = keyboard.readLine("Lead Actor?");
actor2 = keyboard.readLine("Supporting Actor?");
director = keyboard.readLine("Director?");
String videoTitles = film+actor1+actor2+director;
titles.add(new Title(codeNum, videoTitles));
screen.println(titles);
SimpleWriter outFile = new SimpleWriter("title_test.txt");
titles.saveTo(outFile);
outFile.close();
}In the main class I thought I was closing the file with the code,
outFile.close();Any ideas how to solve these problems? -
Converting punctuated strings to Unpunctuated strings
I need to fiqure out how to convert punctuated strings to non-punctuated strings.
E.G
"This is my dog, her name is pinky."
"This is my dog her name is pinky"
The string is allowed to contain characters btw. a-z and A-Z. It is also allowed to have spaces, apostrophe and hyphens. Thank you.I think you have to copy the string to a string buffer (to make it mutable) then using loops, loop through the string char by char making sure if falls within the bounds set. If it is not then discard it.
Hope this helps, there may be a better way, but i dont know it -
Converting contents of a file to String
Hi,
I need to read a pdf file and obtain its contents in the form of a String; pass this string to a method which will recreate this file in pdf format (this is a requirement).
How can this be done ?
I tried using RandomAccessFile but the output file is not a proper pdf format (it shows an error on opening).
If i purely work on the byte stream level (i.e. use a byte array instead of a String representation of the input file), the output file is of a proper pdf format and i am able to open it successfully.
Also i tried first obtaining a byte array and then converting it to a String by passing it to the String constructor i.e.
String fileStr = new String(byte[] fileBytes);and then i pass this string to the method and if that method tries to obtain the byte array from this String and create the output pdf file, i again am not able to open this file.
Any suggestions would be highly appreciated.Hi,
I need to read a pdf file and obtain its contents in
the form of a String; pass this string to a method
which will recreate this file in pdf format (this is
a requirement).Since PDF files are binary files then this requirement needs to be changed.
>
How can this be done ?It cannot be done safely unless you are willing to use something like Base64 or Hex encoding but I suspect this is not what you want. -
Cannot convert ÿØÿà of type class java.lang.String to class BFileDomain.
Hi All,
I am using Jdeveloper 11.1.2.3.0.
I have a scenario of making an ADF page where I have a IMAGE field to show on the page. So,I have a table called "PRODUCT" with fields called photo with BFILE type. Now when I the data i have inserted using the DML command and i can see the path at the backend.
However,when i am runnig my ADF page in the Filed called "PHOTO" I can only see a junk character stating 'yoyo'.
When I click on it, it says ERROR "Cannot convert ÿØÿà of type class java.lang.String to class oracle.jbo.domain.BFileDomain".
Your help will be appreciated ASAP.
Regards,
ShahnawazHi,
did you show the id-value in the user interface as a input-component, and did the input-component include a converter?
If yes, show the id as output-text and remove any existing converter-components.
Best Regards -
Converting hexadecimal XML data to a string
Hello!
Until now I generated XML data with the FM 'SDIXML_DOM_TO_XML'.
After that I did a loop over the xml_as_table in which I was casting each line of that table to a string.
ASSIGN <line> TO <line_c> CASTING.
After the inftroduction of unicode in our system I get a error:
In the current program an error occured when setting the field symbol <LINE_C> with ASSIGN or ASSIGNING (maybe in combination with the CASTING addition).
When converting the base entry of the field symbol <LINE_C> (number in base table: 32776), it was found that the target type requests a memory alignment of 2
What does it mean? Does somebody have a solution.
I need this function for sending this XML data as string over a simple old CPIC connection.
Best regards
MartinHello Martin
Perhaps my sample report ZUS_SDN_XML_XSTRING_TO_STRING provides a solution for your problem.
*& Report ZUS_SDN_XML_XSTRING_TO_STRING
*& Thread: Converting hexadecimal XML data to a string
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1029652"></a>
REPORT zus_sdn_xml_xstring_to_string.
*-- data
*-- read the XML document from the frontend machine
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: xml_table TYPE TABLE OF xml_line.
DATA: go_xml_doc TYPE REF TO cl_xml_document,
gd_xml_string TYPE string,
gd_rc TYPE i.
PARAMETERS:
p_file TYPE localfile DEFAULT 'C:payload_idoc.xml'.
START-OF-SELECTION.
CREATE OBJECT go_xml_doc.
" Load XML file from PC and get XML itab
CALL METHOD go_xml_doc->import_from_file
EXPORTING
filename = p_file
RECEIVING
retcode = gd_rc.
CALL METHOD go_xml_doc->get_as_table
IMPORTING
table = xml_table
* size =
* retcode =
" NOTE: simulate creation of XML itab
go_xml_doc->display( ).
create object go_xml_doc.
CALL METHOD go_xml_doc->parse_table
EXPORTING
table = xml_table
* size = 0
receiving
retcode = gd_rc.
CALL METHOD go_xml_doc->render_2_string
* EXPORTING
* pretty_print = 'X'
IMPORTING
retcode = gd_rc
stream = gd_xml_string
* size =
write: / gd_xml_string.
END-OF-SELECTION.
Regards
Uwe -
Cannot convert between unicode and non-unicode string datatypes
My source is having 3 fields :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
My destination is :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
But still I am getting this error :
Column ItemCode cannot convert between unicode and non-unicode string datatypes.
As I am new to SSIS , please show me step by step.
Thanks In Advance.My source is having 3 fields :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
My destination is :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
But still I am getting this error :
Column ItemCode cannot convert between unicode and non-unicode string datatypes.
As I am new to SSIS , please show me step by step.
Thanks In Advance.
HI Subu ,
there is some information gap , what is your source ? are there any transformation in between ?
If its SQL server source and destination and the datatype is as you have mentioned I dont think you should be getting such errors ... to be sure check advance properties of your source and check metada of your source columns
just check simple oledb source as
SELECT TOP 1 ItemCode = cast('111' as nvarchar(50)),DivisionCode = cast('222' AS nvarchar(50)), Salesplan = cast(3.3 As float) FROM sys.sysobjects
and destination as you mentioned ... it should work ...
somewher in your package the source columns metadata is not right .. and you need to convert it or fix the source.
Hope that helps
-- Kunal
Hope that helps ... Kunal -
I want to take a series of hex characters in a string control and produce an HDLC string indicator for example if the data string control is 3F27 then the HDLC string indicator is 7E003F2700B57E
"thanks for your help "
Does that mean you figured it out already?
If not, see this thread for some HDLC related code.
http://forums.ni.com/ni/board/message?board.id=170&message.id=146859&query.id=3388#M146859
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Converting from xsd:string into soapenc:string
Hi.
I was successfull in invoking an axis web service with complex type definitions.
However, when building and deploying the process flow, I get a warning message as follows:
" [bpelc] [Warning]: Trying to assign incompatible types
[bpelc] [Description]: in line 53 of "C:\eclipse\workspace\ComplexTypeWSFlow\TimeSheetProcess.bpel", <from> value type "{http://www.w3.org/2001/XMLSchema}string" is not compatible with <to> value type "{http://schemas.xmlsoap.org/soap/encoding/}string".
[bpelc] [Potential fix]: Please make sure that the return value of from-spec query is compatible with the to-spec query.
[bpelc]
[bpelc] [Warning]: Trying to assign incompatible types
[bpelc] [Description]: in line 58 of "C:\eclipse\workspace\ComplexTypeWSFlow\TimeSheetProcess.bpel", <from> value type "{http://www.w3.org/2001/XMLSchema}string" is not compatible with <to> value type "{http://schemas.xmlsoap.org/soap/encoding/}string".
[bpelc] [Potential fix]: Please make sure that the return value of from-spec query is compatible with the to-spec query."
My question is:
How can I convert between xsd:string and soapenc:string types when using the "assign" activity so I don't keep getting this warning message?
RegardsHi Paulo,
This warning has been fixed in recent builds. eventhough soapenc:string is different type, it extends xs:string and its simple content. the compiler shouldn't display warnings for this case.
Maybe you are looking for
-
Opening Hyperlinks inside Excel WebAccess webpart in the Same Window
I was trying to access Excel Web parts hyperlink like below, but this solution is not working for me. $(document).ready(function() { $(".ewr-sheetcontainer a").each(function(){ $(this).attr("onclick","openLink(this)"); function openLink(Atagpropertie
-
I want to call External Java class from the PL/SQL
Hi, I am using Oracle Apps R11i (11.5.7), I wanted to call external Java class from the PL/SQL. This external Java class is residing in another application server. How do I do this. I know one way. Develop C routine in Oracle Apps to call external ja
-
I was try to research an item I wanted to purchase and I noticed that I didn't have my "invisable hand" to find the lowest price. So I went to Mozzilla to find the problem. Only to find out I only had a blank page. I followed the suggestion on the he
-
The screen shows problems with iCloud only choices are ignore or settings, however nothing I do will unlock it from this screen, cannot power off keeps that bubble on the screen. What do I do?
-
Transform sap query into transaction
hi! my question is not related to mm but also not to other forums in this site. i'm trying to transform sap query into transaction using se93 transaction. i just learing sap in a class and we use an old version of sap. user group name: ofer6 infoset