Convert values in loop to correct data types
I need to convert the values in a loop to the correct data types. It compiles, but I get an error. It says,
Exception in thread "main" java.lang.NumberFormat Excepton: A
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at ExtFile.main(ExtFile.java:22)
Here is the code:
import java.text.* ;
import java.io.* ;
class ExtFile
public static void main (String args[]) throws IOException
// Open the external file whose file name was provided as a
// command line program invocation argument.
ExternalFile dataFile = new ExternalFile(args[0]);
String dataLine = dataFile.getLine();
char candidate;
int curPrecinct;
String precinctIn;
while (!dataFile.havehitEOF())
precinctIn = dataFile.getLine();
candidate = dataLine.charAt(0);
curPrecinct = Integer.parseInt(dataFile.getLine());
// Get data line to process
dataLine = dataFile.getLine();
System.out.println(dataLine);
} // EndWhile
// Close the data file
dataFile.close();
} // EndMain
} // Endclass ExtFile
What does this exception mean and how might I fix it??
Hello,
The line of code:
curPrecinct = Integer.parseInt(dataFile.getLine());accepts a String (stored in a file) and produces an int (an integer representation of the String). However, if you pass it a String which doesn't represent a integer an exception is thrown. For example, if you want to obtain an integer from the String "123a", an exception will arise because you can not parse "123a" into an int because 123a is not an int, that is, it has a letter 'a' in it - and ints do not.
To correct this you must pass (make the line in the file) represent an int.
I hope this works.
Similar Messages
-
In the attached VI why does one loop coerce the data type while the other doesn't?
In the attached VI why does one loop coerce the data type while the other doesn't?
Solved!
Go to Solution.
Attachments:
AAA.vi 8 KBI'm guessing you created the Enum on the front panel. If you right-click it and create an indicator, it will match the type, and be an enum. LabVIEW represents enums as U16, but because the types aren't identical (for example, your enum has 3 values, but a U16 has 65,536 values), LabVIEW automatically coerces (or converts) the smaller (enum) representation into the larger (U16) value.
-
Hi there,
I am having a kind of weird issues with my oracle enterprise db which was perfectly working since 2009. After having had some trouble with my network switch (replaced the switch) the all network came back and all subnet devices are functioning perfect.
This is an NFS for oracle db backup and the oracle is not starting in mount/alter etc.
Here the details of my server:
- SunOS 5.10 Generic_141445-09 i86pc i386 i86pc
- Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
- 38TB disk space (plenty free)
- 4GB RAM
And when I attempt to start the db, here the logs:
Starting up ORACLE RDBMS Version: 10.2.0.2.0.
System parameters with non-default values:
processes = 150
shared_pool_size = 209715200
control_files = /opt/oracle/oradata/CATL/control01.ctl, /opt/oracle/oradata/CATL/control02.ctl, /opt/oracle/oradata/CATL/control03.ctl
db_cache_size = 104857600
compatible = 10.2.0
log_archive_dest = /opt/oracle/oradata/CATL/archive
log_buffer = 2867200
db_files = 80
db_file_multiblock_read_count= 32
undo_management = AUTO
global_names = TRUE
instance_name = CATL
parallel_max_servers = 5
background_dump_dest = /opt/oracle/admin/CATL/bdump
user_dump_dest = /opt/oracle/admin/CATL/udump
max_dump_file_size = 10240
core_dump_dest = /opt/oracle/admin/CATL/cdump
db_name = CATL
open_cursors = 300
PMON started with pid=2, OS id=10751
PSP0 started with pid=3, OS id=10753
MMAN started with pid=4, OS id=10755
DBW0 started with pid=5, OS id=10757
LGWR started with pid=6, OS id=10759
CKPT started with pid=7, OS id=10761
SMON started with pid=8, OS id=10763
RECO started with pid=9, OS id=10765
MMON started with pid=10, OS id=10767
MMNL started with pid=11, OS id=10769
Thu Nov 28 05:49:02 2013
ALTER DATABASE MOUNT
Thu Nov 28 05:49:02 2013
ORA-00202: control file: '/opt/oracle/oradata/CATL/control01.ctl'
ORA-27037: unable to obtain file status
Intel SVR4 UNIX Error: 79: Value too large for defined data type
Additional information: 45
Trying to start db without mount it starts without issues:
SQL> startup nomount
ORACLE instance started.
Total System Global Area 343932928 bytes
Fixed Size 1280132 bytes
Variable Size 234882940 bytes
Database Buffers 104857600 bytes
Redo Buffers 2912256 bytes
SQL>
But when I try to mount or alter db:
SQL> alter database mount;
alter database mount
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
SQL>
From the logs again:
alter database mount
Thu Nov 28 06:00:20 2013
ORA-00202: control file: '/opt/oracle/oradata/CATL/control01.ctl'
ORA-27037: unable to obtain file status
Intel SVR4 UNIX Error: 79: Value too large for defined data type
Additional information: 45
Thu Nov 28 06:00:20 2013
ORA-205 signalled during: alter database mount
We have already checked in everywhere in the system, got oracle support as well without success. The control files are in the place and checked with strings, they are correct.
Can somebody give a clue please?
Maybe somebody had similar issue here....
Thanks in advance.Did the touch to update the date, but no joy either....
These are further logs, so maybe can give a clue:
Wed Nov 20 05:58:27 2013
Errors in file /opt/oracle/admin/CATL/bdump/catl_j000_7304.trc:
ORA-12012: error on auto execute of job 5324
ORA-27468: "SYS.PURGE_LOG" is locked by another process
Sun Nov 24 20:13:40 2013
Starting ORACLE instance (normal)
control_files = /opt/oracle/oradata/CATL/control01.ctl, /opt/oracle/oradata/CATL/control02.ctl, /opt/oracle/oradata/CATL/control03.ctl
Sun Nov 24 20:15:42 2013
alter database mount
Sun Nov 24 20:15:42 2013
ORA-00202: control file: '/opt/oracle/oradata/CATL/control01.ctl'
ORA-27037: unable to obtain file status
Intel SVR4 UNIX Error: 79: Value too large for defined data type
Additional information: 45
Sun Nov 24 20:15:42 2013
ORA-205 signalled during: alter database mount -
[SOLVED] Value too large for defined data type in Geany over Samba
Some months ago Geany started to output an error whith every attempt to open a file mounted in smbfs/cifs.
The error was:
Value too large for defined data type
Now the error is solved thanks to a french user, Pierre, on Ubuntu's Launchpad:
https://bugs.launchpad.net/ubuntu/+bug/ … comments/5
The solution is to add this options to your smbfs/cifs mount options (in /etc/fstab for example):
,nounix,noserverino
It works on Arch Linux up-to-date (2009-12-02)
I've writed it on the ArchWiki too: http://wiki.archlinux.org/index.php/Sam … leshootingAn update on the original bug. This is the direct link to launchpad bug 455122:
https://bugs.launchpad.net/ubuntu/+sour … bug/455122 -
'Value too large for defined data type' error while running flexanlg
While trying to run flexanlg to analyze my access log file I have received the following error:
Could not open specified log file 'access': Value too large for defined data type
The command I was running is
${iPLANET_HOME}/extras/flexanlg/flexanlg -F -x -n "Web Server" -i ${TMP_WEB_FILE} -o ${OUT_WEB_FILE} -c hnrfeuok -t s5m5h5 -l h30c+5 -p ctl
Which should generate a html report of the web statistics
The file has approx 7 Million entries and is 2.3G in size
Ideas?I've concatenated several files together from my web servers as I wanted a single report, several reports based on individual web servers is no use.
I'm running iWS 6.1 SP6 on Solaris 10, on a zoned T2000
SunOS 10 Generic_118833-23 sun4v sparc SUNW,Sun-Fire-T200
Cheers
Chris -
Mkisofs: Value too large for defined data type too large
Hi:
Does anyone meet the problem when use mkisofs command?
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Warning: creating filesystem that does not conform to ISO-9660.
mkisofs 2.01 (sparc-sun-solaris2.10)
Scanning iso
Scanning iso/rac_stage1
mkisofs: Value too large for defined data type. File iso/rac_stage3/Server.tar.gz is too large - ignoring
Using RAC_S000 for /rac_stage3 (rac_stage2)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Thanks!An update on the original bug. This is the direct link to launchpad bug 455122:
https://bugs.launchpad.net/ubuntu/+sour … bug/455122 -
OPMN Failed to start: Value too large for defined data type
Hello,
Just restared opmn and it failed to start with folloiwing errors in opmn.log:
OPMN worker process exited with status 4. Restarting
/opt/oracle/product/IAS10g/opmn/logs/OC4J~home~default_island~1: Value too large for defined data type
Does anyone have ideas about cause of this error? Server normally worked more than 6 month with periodic restarts...Hi,
You could get error messages like that if you try to access a file larger than 2GB on a 32-bit OS. Do you have HUGE log files?
Regards,
Mathias -
Moving Values to fields of different data types- Conversion
I'm having trouble figuring out how to move a value from a field of a <b>char type</b> to a field of <b>structure RSDSSELOPT</b> type in a different itab.
I'll show you what I have so far.
DATA: BEGIN OF ITABAPI OCCURS 0,
SEARCHFLD LIKE ZDOLTARC03-SEARCHFLD,
VALUE LIKE ZDOLTARC03-VALUE,
END OF ITABAPI.
DATA: BEGIN OF ITAB_GO occurs 0,
FIELDNAME LIKE RSDSTABS-PRIM_FNAME,
SELOPT_T TYPE RSDS_SELOPT_T,
END OF ITAB_GO.
LOOP AT ITABAPI.
MOVE: ITABAPI-SEARCHFLD TO ITAB_GO-FIELDNAME,
<b>ITABAPI-VALUE TO ITAB_GO-SELOPT_T.</b>
APPEND ITAB_GO.
ENDLOOP.
As an alternative I tried feeding the value into ITAB_GO-selopt_t-low, but breaking down the structure that far may be beyond the capabilities of the processor.
If anyone knows a way to feed a char value into the structure field please help.
N LHi Natasha,
my advice is: don't try to do it in just step. Instead,
DATA: LT_RANGE TYPE TABLE OF RSDSSELOPT WITH HEADER LINE.
LOOP AT ITABAPI.
MOVE: ITABAPI-SEARCHFLD TO ITAB_GO-FIELDNAME.
CLEAR: LT_RANGE.
REFRESH: LT_RANGE.
LT_RANGE-SIGN = 'I'.
LT_RANGE-OPTION = 'EQ'.
LT_RANGE-LOW = ITABAPI-VALUE.
APPEND LT_RANGE.
ITAB_GO-SELOPT_T[] = LT_RANGE[].
APPEND ITAB_GO.
ENDLOOP.
Pls let us know if it helped. BR,
Alvaro -
Using Calc Manager to update values for Members with Text Data Type
Hi All,
In my outline I have a member of text data type. The purpose is to allow users to be able to enter comments.
Each line item is created through a business rule and I am prompting the user to enter the key values at the launch of the calc manager rules. I want to be able to prompt the user for the comments in the calc manager rule because I know that it supports variables of type string. However I am unable to assign this string variable directly to the member.
I appreciate that essbase only stores numeric data and that all text data type members really store numeric values which are basically the id's of the text string stored in a relational table by planning. however I cannot update the database table through calc manager and then bring in the generated id. Is there any way I can do this?
I don't want to skip this field in the calc manager rule and expect the user to enter the comments AFTER the line item has been created because the users want this to be a mandatory field and insist that a new line item not be created unless comments are specified.
Many thanks in advance for any help I can get.
ShehzadIf the comments are a set definition you could you smart lists in your planning forms.
create this in your smart list
xxxx = 1
yyyy = 2 -
Cannot get the correct data type in Oracle JDBC
Dear ALL:
I used JDBC ResultSetMetaData to get the column data type for Oracle Database. I created a table including 2 columns AAA, which is NUMBER type, BBB which is FLOAT type.
However, I found a problem that either NUMBER or FLOAT data types are reported as NUMBER type in JDBC.
IN SQL 2000, it is okay. SMALLINT, INT, TINYINT, etc..can be reported correctly.
Can anybody tell me that what's wrong here? I will be very appreciated.hi,
i guess its a bug which is fixed with 10i.
Elango. -
JCo getting truncated value from SAP when field data type is RAW
We are trying to fetch data from a SAP-AII table by using JCo using the RFC RFC_READ_TABLE.
We are getting incomplete data when the data type of the column is RAW in a particular table.A typical case is:
Table Name: /AIN/DM_DEVCTR
Field : CLIENT Type: CLNT Length:3 Value: 100 (SAP Generated)
Field: DEVCTR_GUID Type:RAW Length:16 Value: 306F50F53805ED488DE9797AC86B5728 (SAP Generated)
Filed: DEVCTR_ID Type:CHAR Length:128 Value: KDEVICECONTROLLER (User input)
For the fields CLIENT and DEVCTR_ID we get the entire value (including blank spaces) but for DEVCTR_GUID we get only 16 characters whereas SAP-AII stores a value that is 32 characters in length. How do we fetch the actual value instead of the truncated value?
Sample code is attached.
try {
mConnection = JCO.createClient("100", // SAP client
"User", // userid
"Password", // password
"EN", // language
"SAP", // host name
"00"); // system number
mConnection.connect();
if (mConnection == null) {
System.out.println("Connection to SAP Server failed.");
mRepository = new JCO.Repository("User", mConnection);
ftemplate = mRepository.getFunctionTemplate("RFC_READ_TABLE");
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
JCO.Function function = ftemplate.getFunction();
JCO.ParameterList importParamList = function.getImportParameterList();
importParamList.setValue("/AIN/DM_DEVCTR", "QUERY_TABLE");
importParamList.setValue(";", "DELIMITER");
JCO.Table tableData = function.getTableParameterList().getTable("DATA");
JCO.Table fields = function.getTableParameterList().getTable("FIELDS");
mConnection.execute(function);
if (tableData.getNumRows() > 0) {
do {
for (JCO.FieldIterator e = tableData.fields(); e
.hasMoreElements();) {
JCO.Field field = e.nextField();
String str = field.getString();
String[] values = str.split(";");
for(int i = 0; i < values.length; i++){
System.out.println(values<i>);
} while (tableData.nextRow());
} else {
System.out.println("No results found");
mConnection.disconnect();Hi Kaanu,
You have to modify your java code.
String val = new String( field.getByteArray());
PS: Please reward points for helpful answer or problem resolved. -
Null value for int and datetime date type in xml schema
hi:
I am embarrassed by a qustion in xml schema; i defined a xml schema file like
this:
<elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:element name="test">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="password" type="xs:string" nillable="true"/>
<xs:element name="user" type="xs:int" nillable="true"/>
<xs:element name="s_time" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and I send this file to workflow clientrequest() node, I wanted to receive data
in this schema file.but when i send null value to the element "user" and "s_time"
in workshop test tool(test soap),and use function in xmlbean like isNilUser or
isNilStime, one error occur.
I don't kown why, I had to ask the engineer of bea in china, one told me a bug.
is that true?Visakh16 I cant agree more with you on it, it is good but in production u cant have them change maxrows. I think
Patrick Hurst is a better option. debug the package have it running and move up
Please mark as helpful and propose as answer if you find this as correct!!! Thanks,Dia Agha .
Hmm..Why do you need to change it in production?
What I suggested was to tweak the setting in dev machine so that it interprets the Excel file datatypes correctly when doing development. Once mapping is set correctly then it will work fine when in production or in any other environment. The tweaking is
just to make sure it interprets the datatype correctly at design time and has nothing to do with production deployment
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
How do I ensure a Map key maps to the correct data type?
Hi,
I have a simple event processing interface, where an Action class processes an event, and optionally generates a response event. I want to store a map of all registered actions, and then select the one matching an incoming event at run time:
// the basic types
public abstract class Event {
protected String type;
protected String data;
public String getType() { return type; }
@Override
public String toString() { return data; }
// an action processes a request event and optionally returns a response event
public interface Action<ReqE extends Event, ResE extends Event> {
public ResE process(ReqE request);
// two simple events
public class Event1 extends Event {
public Event1(String data) { this.type = "ev1"; this.data = data; }
public class Event2 extends Event {
public Event2(String data) { this.type = "ev2"; this.data = data; }
// simple test class
public class Test {
Map<String, Action<? extends Event, ? extends Event>> actions
= new HashMap<String, Action<? extends Event, ? extends Event>>();
public void run() {
// source event
Event1 request = new Event1("hello");
// register an action - takes an Event1 and returns an Event2
actions.put(request.getType(), new Action<Event1, Event2>() {
@Override
public Event2 process(Event1 req) {
return new Event2(req.data);
// run it
Action<Event, Event> action = getAction(request.getType());
Event response = action == null ? null : action.process(request);
System.out.println("Response=" + String.valueOf(response));
public Action<Event, Event> getAction(String type) {
return (Action<Event, Event>)actions.get(type);
public static void main(String[] args) {
new Test().run();
}This all works, but the problem is obviously the cast in the getAction() method. I can see what the problem is: there is nothing to stop me registering a handler with the wrong event types:
// register an action - this will fail at runtime as request is an Event1
actions.put(request.getType(), new Action<Event3, Event4>() {
@Override
public Event4 process(Event3 req) {
return new Event4(req.data);
});So that leads to the map declaration. What I think I need to do is change the key of the map from String to... well, I'm not sure what! Some kind of parameterised EventType class that ties in to the event types of the parameterised Action class, so when I call:
Map<????, Action<? extends Event, ? extends Event>> actions = ...
actions.put(????, new Action<Event1, Event2>() {...});the key type ties in to Event1/Event2 so that it ensures the eventual call to "process" will receive the correct types. But this is really getting beyond my knowledge of generics!
So if anybody has any useful pointers on where to go from here I'd be realy grateful.
Cheers,
BarneyThe obvious choice for the key would be the type of the request event instead of a plain String.
Thus, declare the map like this:
Map<Class<? extends Event>, Action<?,?>>Below, I've modified your code so that it is typesafe, provided you use the public methods "registerAction" and "getAction".
import java.util.HashMap;
import java.util.Map;
abstract class Event {
protected String type;
protected String data;
public String getType() { return type; }
@Override
public String toString() { return data; }
// an action processes a request event and optionally returns a response event
interface Action<ReqE extends Event, ResE extends Event> {
public ResE process(ReqE request);
// two simple events
class Event1 extends Event {
public Event1(String data) { this.type = "ev1"; this.data = data; }
class Event2 extends Event {
public Event2(String data) { this.type = "ev2"; this.data = data; }
// simple test class
public class EventTest {
Map<Class<? extends Event>, Action<?,?>> actions
= new HashMap<Class<? extends Event>, Action<?,?>>();
public void run() {
// source event
Event1 request = new Event1("hello");
// register an action - takes an Event1 and returns an Event2
registerAction(Event1.class, new Action<Event1, Event2>() {
public Event2 process(Event1 req) {
return new Event2(req.data);
// run it
Action<? super Event1,?> action = getAction(Event1.class);
Event response = action == null ? null : action.process(request);
System.out.println("Response=" + String.valueOf(response));
@SuppressWarnings("unchecked")
public <E extends Event> Action<? super E,?> getAction(Class<E> type) {
return (Action<? super E,?>)actions.get(type);
public <E extends Event> void registerAction(Class<E> type, Action<? super E,?> action) {
actions.put(type, action);
public static void main(String[] args) {
new EventTest().run();
} -
Value too large for defined data type
Hi,
i have a Sun Netra t1 105. Sometimes when I try to start top, i get the error message in $SUBJECT.
Does someone have a hint?
Thanks in advance
Tosh42I've concatenated several files together from my web servers as I wanted a single report, several reports based on individual web servers is no use.
I'm running iWS 6.1 SP6 on Solaris 10, on a zoned T2000
SunOS 10 Generic_118833-23 sun4v sparc SUNW,Sun-Fire-T200
Cheers
Chris -
No-rounding while converting data type F to Packed
Hi All,
I want to pass value of a variable of data type F to another variable of dtata type P with decimals 3.
While converting values decimals are getting rounded to next higher value.
Can any one tell me how to retain the actual values,without rounding off.
Ex. variable 1 = 25.1238567890000 (type F).
when variable 2 is assigned the value of variable 1,then it should consist of the value 25.123(instead of 25.124).
Thanks & Regards
Seshagiri.Hi seshagiri,
it seems that the value you want to pass to (type F) is smaller than the value that you are using in your code.
Can I ask what is the actual use of the value type P? if there is processing to be done then I suggest to try to process the needed code using a common data type then until the later parts of the logic to pass it to data type P.
If the value is only to be used for display then just pass it to a variable of data type C or string to retain the decimals.
Maybe you are looking for
-
Automator: Why can't I add "Take a Picture" to workflow?
I'm pretty sure the digital cameras I have are supported for this action, but I can't even get to that point because when I drag the "Take a Picture" action to the workflow, it won't "stick". Other actions such as "Take a Video Snapshot" add normally
-
The Apple av cables are awesome. They look great and also give a really crisp picture when connecting the video ipod to a t.v. However if your t.v is more than 25 cm from where you plug in the audio leads then make sure you get a coupler and a photo
-
Is it possible to change TreeView's background color, not node color?
In advance, Thanks!! Actually, I've made my own treeview in my project. and I've changed my treeview node color as i want I wonder whether or not to change treeview's background color, not node color in below class. // in ~.fr Class kMyTreeViewWid
-
RFC redirected to sapdp instead of sapgw
Hello I have two RFC connections to two different partners; Both from ECC to ECC through our saprouter. And both partner systems have a logon group or me the connection should be something like : our ECC -> our saprouter (port 3299) -> partner CI (po
-
All add-ons in Greasemonkey userscripts say they're enabled, but aren't working?
I use Greasemonkey for my Tumblr extentions, such as wrapped tags, tumblr h8, dashboard backgrounds, and tumtaster. Today, I downloaded Stylish, and that made all of my greasemonkey extentions stop working, even though they all say enabled. I have re