How to use ImageIcon's byte[] constructor?
As subject states
I've tried many many times and I just cna't get it. I can get it working using ImageIcon's String (filename) constructor, but the application I'm developing for requires the use of a byte[] array.
Could someone please share some code that reads data from an image file (jpg preferably) and converts it into an array of bytes and uses that to (successfully!) create a working ImageIcon?
Thanks
It should work to use a BufferedInputStream instead of BufferedReader and InputStreamReader. I tried this test code.
public static void main(String[] args) throws Exception {
ArrayList byteList=new ArrayList();
byte[] inbytes={12,-127,-126,-2};
ByteArrayInputStream bas=new ByteArrayInputStream(inbytes);
BufferedInputStream br=new BufferedInputStream(bas);
byteList.add(new Integer(br.read()));
byteList.add(new Integer(br.read()));
byteList.add(new Integer(br.read()));
byteList.add(new Integer(br.read()));
byte[] byteArray = new byte[byteList.size()];
for(int i=0;i<byteArray.length;i++) {
byteArray=(byte) (((Integer) byteList.get(i)).intValue());
System.out.println(byteArray[i] );
It displays the same values as the original inbytes values. When I tried the same code except using InputStreamReader and BufferedReader, I did not get the original inbytes values. There's character encoding with a Reader that may change the values. Streams give the raw data.
Similar Messages
-
How to use class.getResource() to create an ImageIcon
Hi,
I am well acquainted with creating and using ImageIcon icons using the ImageIcon constructor
and putting the image file in a folder called Images which is at the same level as the
bin and src folders.
I discovered a demo program, LayeredPaneDemo, that uses class.getResource() to create
an icon and found that in my eclipse version, the icon's image file was not found when
I used the original getResource() call but the icon was created when I used the ImageIcon
constructor.
I posted on JavaRanch and eventually realized that the image file needed to be with the
.class files, so I moved the Images folder under bin and getResource() works fine and I'm
happy.
However, I have three questions for you.
One poster on JavaRanch told me that it's better to use getResource() rather than the
ImageIcon constructor for distributing an app (I'm not distributing anything but want
to do it all correctly).
Do you agree with that or can I safe keep using the ImageIcon constructor?
Another poster told me he doesn't think it's safe to leave the image file in bin because
it might be lost during the build in eclipse and that there is a way to have eclipse copy
the files to bin during the build which should mean that I can leave the images folder at
the level of bin and src.
Do you agree with that?
If yes, how do I get eclipse to copy the file during the build?
P.S.
Before I posted on JavaRanch, I put the Images folder at every level of the project's
directory as shown in eclipse (which is why I missed the bin folder until JavaRanch
whacked me upside the head) and getResource() still didn't work.The contents of the Java Source folder are compiled if they're source files, copied otherwise (assuming no filter's been put in place to prevent copying), so your images belong under a source folder.
-
How to use the JE database with other data types than byte arrays?
Hi! I searched the javadoc of Berkley DB JE, for a way to introduce entry (but I need also retrieve) data with other type than byte arrays, e.g. String, or anything else, as int may be, etc.
Still, I didn't find any such way, because the main (only?!) method to entry data into an open database - according what I found in javadoc - is:
"public OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException"
and both this and the corresponding method for retrieves, are based on the same DatabaseEntry type, which allow only entry data on byte[] support.
What if I need to use Strings or int, or even char? I must do a special conversion from these types, to byte[], to use the database?
Thank you!On the doc page (this is also in the download package),
http://download.oracle.com/docs/cd/E17277_02/html/index.html
see:
Getting Started Guide
Java Collections Tutorial
Direct Persistence Layer (DPL)
All of these describe how to use data types other than byte arrays.
--mark -
How to using the JSP print the byte[] or byte?
how to do?
this byte[]'s content is a PIC,if let this byte[] to string did print is character string, not the PIC.you see?:)
-
How to use Progress Monitors?
how to use Progress Monitors?
in the name of god
hi friends
i have a problem. I am writing a program that read data from a file record by record and store to a database. my problem is here that i want add a progress monitor that when the program is doing its work it appear. I use ProgressMonitorInputStream class but it can not work well. It appear and read file record by record and store in table of database but its progress dont move and do nothing. I know that I have a tiny problem in use this class. Please guide me.
i put my codes below.
best regards
*////this is an event that invoke my classes*
private void readbtnActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(fileName);
//filtering file extension
FileNameExtensionFilter filter = new FileNameExtensionFilter("Text file", "txt");
fileChooser.setFileFilter(filter);
//fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) { //if choose ok button
fileName = fileChooser.getSelectedFile();
ReadTextFile readFile = new ReadTextFile(fileName);
readFile.openFile();
readFile.readRecord();
*//readFile.closeFile(); //if this line enable this message appeare "Scanner closed" .why?*
readFile.closeFile();
} else //if choose cancel button
result = 0; //do nothing
*/////this is readFile class and invoke data access class and insert data in my database*
public class ReadTextFile {
private Scanner input;
private File fileName;
private int i = 1;
DataAccess dal = new DataAccess(); //new a defined my class
AcountRecord record = new AcountRecord();
public ReadTextFile(File n) { //Constructor
fileName = new File(String.valueOf(n));
this.openFile();
private void setRecord(String val) {
try {
record.setId(Integer.parseInt(val.substring(1, 5)));
record.setTime(Integer.parseInt(val.substring(8, 12)));
record.setDate(Integer.parseInt(val.substring(15, 21)));
record.setMode(val.substring(24, 26));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "ÇäÊÎÇÈ ÔãÇ äÇÏÑÓÊ ÇÓÊ.","Set Record Method",JOptionPane.ERROR_MESSAGE);
public void openFile() {
try {
input = new Scanner(fileName);
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "ÇäÊÎÇÈ ÔãÇ äÇÏÑÓÊ ÇÓÊ.","Open File Method",JOptionPane.ERROR_MESSAGE);
public void readRecord() {
new Thread() {
private Component _Main;
@Override
public void run() {
try {
input = new Scanner(fileName);
InputStream in = new FileInputStream(fileName);
ProgressMonitorInputStream pm =
new ProgressMonitorInputStream(_Main, "reading the file", in);
ProgressMonitor pmo = pm.getProgressMonitor( );
pmo.setMaximum( (int) fileName.length());
while (/*input.hasNext() &&*/ pm.read() != -1) {
setRecord(input.next());
dal.Connect();
String sql = "INSERT INTO fileinfo(pkey,id,date,time,mode)VALUES(%s,%s,%s,%s,'%s')";
sql = String.format(sql, i++, record.getId(), record.getDate(), record.getTime(), record.getMode());
dal.doCommand(sql);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage() ," Read Record method.",JOptionPane.ERROR_MESSAGE);
dal.Disconnect();
}.start();
public void closeFile() {
input.close();
}Edited by: firethumbs on Mar 26, 2009 12:43 PMIN THE NAME OF GOD
hi firends
i forget say one thing. if remove while loop content this program will work good. i suppose that the while condition and read file records not similar. because while condition check bytes but in while body read records. is that true?
how can solve this problem?
best regurds -
How to use MapDepthPointToCameraSpace
This is a public-service post. There was so little documentation available about MapDepthPointToCameraSpace -- and no code examples available at all, in the SDK Browser or elsewhere -- that I was compelled to reverse-engineer the method, just to figure out
how to use it, and here is what I discovered.
Here is the syntax of the method:
public CameraSpacePoint MapDepthPointToCameraSpace (
DepthSpacePoint depthPoint,
UInt16 depth
The critical thing to understand about this method, and the source of much boondoggling until I figured it out, is that the input is in
millimeters, while the output is in
meters.
Uint16 depth -> This is a depth value, unsigned integer (two bytes wide), in units of
millimeters.
DepthSpacePoint depthPoint -> This is a struct containing an [x,y] coordinate. The [x,y] describe a 2D coordinate location on the incoming depth-map from the Kinect, with [0,0] at upper-left corner. This struct contains two properties,
X and Y, which are signed floats (four bytes wide); however, you should assign only positive integers to these X and Y properties. There is no constructor for this struct, so you must create a DepthSpacePoint in several steps, shown in the code example below.
CameraSpacePoint -> This is a struct containing an [x,y,z] coordinate. The [x,y,z] describe a 3D coordinate location in the reference space established by the Kinect sensor itself. This struct contains three properties, X and Y and Z,
which are signed floats (four bytes wide), representing coordinates in physical space, in units of
meters. Although z will always be positive (a zero value indicates an unknown depth value or error), each of x and y may be positive, zero, or negative. If MapDepthPointToCameraSpace cannot complete its calculation
successfully -- for example, an object is too close to the sensor -- then any of the [x,y,z] values may be set to +Infinity or to -Infinity. Attempting to use these infinite values will not throw an exception -- instead, you'll find your variables being
set to MAXINT or -MAXINT and you will be completely confused by the end results. So you must carefully screen for infinite values when using MapDepthPointToCameraSpace.
Example usage:
CoordinateMapper m = myKinectSensor.CoordinateMapper;DepthSpacePoint d = new DepthSpacePoint(); // no constructor is availabled.X = 100; // in pixelsd.Y = 200; // in pixelsCameraSpacePoint p = m.MapDepthPointToCameraSpace( d, // in pixels 2500); // in millimeters
The above code queries the coordinate mapper for pixel-coordinate [x,y] = [100,200] in the Kinect depth map, with input depth value of 2500
millimeters. The output is as follows:
p.X, p.Y, and p.Z contain the mapped 3D coordinate in the Kinect's reference spatial system, in floating-point
meters, where:
X and Y will be positive, zero, or negative if calculation succeeds. They will be plus or minus infinity if a calculation error occurs.
Z will be positive if the calculation succeeds. It will be zero or plus or minus infinity if a calculation error occurs.
I hope that this information is helpful to others!
- ZMKThis is a public-service post. There was so little documentation available about MapDepthPointToCameraSpace -- and no code examples available at all, in the SDK Browser or elsewhere -- that I was compelled to reverse-engineer the method, just to figure out
how to use it, and here is what I discovered.
Here is the syntax of the method:
public CameraSpacePoint MapDepthPointToCameraSpace (
DepthSpacePoint depthPoint,
UInt16 depth
The critical thing to understand about this method, and the source of much boondoggling until I figured it out, is that the input is in
millimeters, while the output is in
meters.
Uint16 depth -> This is a depth value, unsigned integer (two bytes wide), in units of
millimeters.
DepthSpacePoint depthPoint -> This is a struct containing an [x,y] coordinate. The [x,y] describe a 2D coordinate location on the incoming depth-map from the Kinect, with [0,0] at upper-left corner. This struct contains two properties,
X and Y, which are signed floats (four bytes wide); however, you should assign only positive integers to these X and Y properties. There is no constructor for this struct, so you must create a DepthSpacePoint in several steps, shown in the code example below.
CameraSpacePoint -> This is a struct containing an [x,y,z] coordinate. The [x,y,z] describe a 3D coordinate location in the reference space established by the Kinect sensor itself. This struct contains three properties, X and Y and Z,
which are signed floats (four bytes wide), representing coordinates in physical space, in units of
meters. Although z will always be positive (a zero value indicates an unknown depth value or error), each of x and y may be positive, zero, or negative. If MapDepthPointToCameraSpace cannot complete its calculation
successfully -- for example, an object is too close to the sensor -- then any of the [x,y,z] values may be set to +Infinity or to -Infinity. Attempting to use these infinite values will not throw an exception -- instead, you'll find your variables being
set to MAXINT or -MAXINT and you will be completely confused by the end results. So you must carefully screen for infinite values when using MapDepthPointToCameraSpace.
Example usage:
CoordinateMapper m = myKinectSensor.CoordinateMapper;DepthSpacePoint d = new DepthSpacePoint(); // no constructor is availabled.X = 100; // in pixelsd.Y = 200; // in pixelsCameraSpacePoint p = m.MapDepthPointToCameraSpace( d, // in pixels 2500); // in millimeters
The above code queries the coordinate mapper for pixel-coordinate [x,y] = [100,200] in the Kinect depth map, with input depth value of 2500
millimeters. The output is as follows:
p.X, p.Y, and p.Z contain the mapped 3D coordinate in the Kinect's reference spatial system, in floating-point
meters, where:
X and Y will be positive, zero, or negative if calculation succeeds. They will be plus or minus infinity if a calculation error occurs.
Z will be positive if the calculation succeeds. It will be zero or plus or minus infinity if a calculation error occurs.
I hope that this information is helpful to others!
- ZMK -
URLConnection.setConnectTimeout(): how to use?
I wonder how to use URLConnection.setConnectTimeout()? I need to have a URLConnection object (in my case: HttpURLConnection). But the only way to do this for an URL is:
HttpURLConnection con = (HttpURLConnection) url.openConnection(); right? But then it's too late to set a connection timeout. HttpURLConnection has only a protected constructor, so I can't use it. Is ther another way?I don't call connect():
con = (HttpURLConnection) url.openConnection(); //can take forever
con.setConnectTimeout(timeout);
con.setReadTimeout(timeout);
//avoid "java.io.IOException: HTTPS hostname wrong: should be <217.5.135.142>"
if (con instanceof HttpsURLConnection) { //HTTPS URL?
((HttpsURLConnection) con).setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
String contentEncoding = con.getContentEncoding();
is = con.getInputStream();
//get correct input stream for compressed data:
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
is = new GZIPInputStream(is); //reads 2 bytes to determin GZIP stream!
Utils.writeStream(is, outputStream); -
How to use the sharing function with other pc on the Finder sidebar?
I discver my housemates' pc's names under "sharing" on the Finder sidebar. We all use the same wifi network at home. Neither they nor I have enabled anything so I'm just wondering what is that for and where am I able to control sharing options?
Also I can even access their iTunes libraries. How do these all work? Am I able to set any security options at all?On the doc page (this is also in the download package),
http://download.oracle.com/docs/cd/E17277_02/html/index.html
see:
Getting Started Guide
Java Collections Tutorial
Direct Persistence Layer (DPL)
All of these describe how to use data types other than byte arrays.
--mark -
How to use methods when objects stored in a linked list?
Hi friend:
I stored a series of objects of certain class inside a linked list. When I get one of them out of the list, I want to use the instance method associated with this object. However, the complier only allow me to treat this object as general object, ( of Object Class), as a result I can't use instance methods which are associated with this object. Can someone tell me how to use the methods associated with the objects which are stored inside a linked list?
Here is my code:
import java.util.*;
public class QueueW
LinkedList qList;
public QueueW(Collection s) //Constructor of QuequW Class
qList = new LinkedList(s); //Declare an object linked list
public void addWaiting(WaitingList w)
boolean result = qList.isEmpty(); //true if list contains no elements
if (result)
qList.addFirst(w);
else
qList.add(w);
public int printCid()
Object d = qList.getFirst(); // the complier doesn't allow me to treat d as a object of waitingList class
int n = d.getCid(); // so I use "Object d"
return n; // yet object can't use getCid() method, so I got error in "int n = d.getCid()"
public void removeWaiting(WaitingList w)
qList.removeFirst();
class WaitingList
int cusmNo;
String cusmName;
int cid;
private static int id_count = 0;
/* constructor */
public WaitingList(int c, String cN)
cusmNo = c;
cusmName = cN;
cid = ++id_count;
public int getCid() //this is the method I want to use
return cid;Use casting. In other words, cat the object taken from the collection to the correct type and call your method.
HashMap map = /* ... */;
map.put(someKey, myObject);
((MyClass)(map.get(someKey)).myMethod();Chuck -
How to use TCP Checksum Off-load in my network driver
I am seeking infomation on how to use TCP Checksum Off-load to tell the Solaris 8 stack not to handle it for both receives and transmits (and let our NIC handle this compute-intensive task instead).
There is mention that Sun GigabitEthernet Adapter cards, Release 1.1 supports Sol-2.6 use of NIC features: TCP checksum offload & byte swapping
There are limited bits of info in include files. For example
sys/strick.h indicates use of:
inetcksum_t's ick_xmit
stream.h has:
struct datab's unsigned u16:16; /* used to store hw-calculated cksum
#define STRUIO_IP 0x04 /* IP checksum stored in db_struioun */
#define STRUIO_ZC 0x08 /* mblk eligible for zero-copy */
strsub.h has:
struct zero_copy_kstat
Also /include/inet/tcp.h has tcp_sum for outbound.
Thank you. -Weimin TchenVenK7337,
Could you show your python code. so we know what your are "writing" to the ethernet port?
That way we can see what you are receiving.
Parsing the incoming data (from the TCP-read) depends heavily on the device that sends it, and can not generically be described. LabVIEW has many byte (and even bit) manipulation functions to convert many different data formats to its own build in formats.
So after the TCP listener is connected, you are constantly reading from the established connection (until it gets broken of course). More advanced example would be the internet toolkit if oyu have it.
From the read characters (and I hope you designed a protocol with a clear starting character, ending character and maybe even a build in checksum) you parse the data and perform you action, and of course generate a reply. Again the internet toolkit is a good example. It parsed the input as it comes it, based on the HTTP format. Then generates the reply based on the request received.
These days I would suggest not to use binairy encoded numerics. Try and use XML formatted data. Yes, it causes a lot of overhead. But typically this is not an issue and makes the code a lot more portable and maintainable. Also makes it easier to interface with other languages/platforms.
Umless of course you are looking at Khz data rates, then XML is not th preferred choice.
Hope this helps... -
How to use the pps function from JCOP?
Hi
I'm trying to use the pps function from JCTerminal (JCOP API: [url http://www.cs.ru.nl/~woj/jcopapi/com/ibm/jc/JCTerminal.html#pps(int, int)]pps function ) to connect my client to a virtual card with a specific protocol (T=0).
But I always got the error: "Protocol and parameter selection not supported by this terminal!"
I've tried to make an ATR that support both protocol : [url http://smartcard-atr.appspot.com/parse?ATR=3b909580811fc7dc]3B 90 95 80 81 1F C7 DC.
I really don't know what value to put in the second parameter (baud rate), I've tried with 150000, which is in the range of the ATR but I'm not sure this is correct. And I could't find any example of it.
I'm also not sure where to put the pps command, the specification say directly after a reset, so I tried this implementation:
System.out.print("Start");
readers = TerminalFactory.getDefault().terminals().list(State.CARD_PRESENT);
//If no readers has a card it ends the process
if(readers.isEmpty()){
System.out.println("\nNo card in the reader...");
return;
System.out.println("\nReader Type: "+readers.get(0).toString());
term = (PCSCJCTerminal)JCTerminal.getInstance("PCSC", readers.get(0).toString().substring(15));
term.open();
System.out.println("\nTerminal opened");
//Getting the ATR
atr = new ATR(term.waitForCard(2000));
try {
term.pps(JCTerminal.PROTOCOL_T0, (int)150000);
} catch (Exception e) {
e.printStackTrace();
System.out.println("ATR: "+toHex(atr.getBytes()));
//sending a data 11223344
System.out.println("\nsending data: 11223344");
byte[] responsesend = term.send(0,cmdsend,0,cmdsend.length);
System.out.println("Response data is:" + toHex(responsesend));
//close terminal
term.close();
System.out.println("\nTerminal closed");I've got this output on the console:
<font size="2">StartReader Type: PC/SC terminal Virtual CAD Reader 0
Terminal opened
ATR: 3b 90 95 90 00 81 1f c7 cc
sending data: 11223344
<font color="red">Protocol and parameter selection not supported by this terminal!</font>
at com.ibm.jc.JCTerminal.pps(Unknown Source)
at com.test.essai.main(essai.java:46)
</font>>
And If I take a look at the data exchanged with the card:
<font size="2">Running in Virtual Card mode...
ATR: 3B909580811FC7DC
Waiting for event (power: off, protocol: unknown/undefined)...
Waiting for event (power: off, protocol: unknown/undefined)...
Raw event data: 01
Event: VCAD_EC_POWER_ON (0x01)
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_POWER_ON) ATR: 3b909580811fc7dc
Raw reply data: 003b909580811fc7dc
Sending reply...
Waiting for event (power: on, protocol: unknown/undefined)...
Waiting for event (power: on, protocol: unknown/undefined)...
Raw event data: 06ff11957b
Event: VCAD_EC_EXCHANGE_TPDU (0x06) C-TPDU: ff11957b
Accepting any PPS request parameters: Protocol: t=1; FI=9, DI=5
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_EXCHANGE_TPDU) R-TPDU: ff11957b
Raw reply data: 00ff11957b
Sending reply...
</font>>
This (above) is the PPS command but not from the PPS function, it is always sent with protocol T=1
<font size="2">Waiting for event (power: on, protocol: t=1)...
Raw event data: 0501
Event: VCAD_EC_SET_PROTOCOL (0x05) Protocol: t=1
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_SET_PROTOCOL)
Raw reply data: 00
Sending reply...
Waiting for event (power: on, protocol: t=1)...
Raw event data: 0600c10120e0
Event: VCAD_EC_EXCHANGE_TPDU (0x06) C-TPDU: 00c10120e0
Handling protocol-specific command...
Protocol block:
NAD: 0x00
PCB: 0xc1 (T1_S_BLOCK); S-Block type: T1_SBT_IFS_REQ
LEN: 1
INF:
IFS: 20
EDC: 0xe0
Changing IFS(other) from 32 to 32
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_EXCHANGE_TPDU) R-TPDU: 00e10120c0
Raw reply data: 0000e10120c0
Sending reply...
Waiting for event (power: on, protocol: t=1)...
Raw event data: 0600001300a404000d54657374436c69656e7441707000f0
Event: VCAD_EC_EXCHANGE_TPDU (0x06) C-TPDU: 00001300a404000d54657374436c69656e74
41707000f0
Processing app. command...
App. block:
NAD: 0x00
PCB: 0x00 (T1_I_BLOCK); Seq. #: 0; More data: 0
LEN: 13
INF:
00a404000d54657374436c69656e7441707000
EDC: 0xf0
cmd name: N/A (class #4)
cmd: 00a40400 0d 54657374436c69656e74417070 70
Responding with the reversed command data, SW is hardcoded to 90<INS>
rsp: 707041746e65696c4374736554 90a4
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_EXCHANGE_TPDU) R-TPDU: 00000f70704
1746e65696c437473655490a475
Raw reply data: 0000000f707041746e65696c437473655490a475
Sending reply...
Waiting for event (power: on, protocol: t=1)...
Raw event data: 060040041122334400
Event: VCAD_EC_EXCHANGE_TPDU (0x06) C-TPDU: 0040041122334400
Processing app. command...
App. block:
NAD: 0x00
PCB: 0x40 (T1_I_BLOCK); Seq. #: 1; More data: 0
LEN: 4
INF:
11223344
EDC: 0x00
cmd name: N/A (class #1)
cmd: 11223344
Responding with the reversed command data, SW is hardcoded to 90<INS>
rsp: 9022
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_EXCHANGE_TPDU) R-TPDU: 0040029022f
0
Raw reply data: 000040029022f0
Sending reply...
Waiting for event (power: on, protocol: t=1)...
Raw event data: 03
Event: VCAD_EC_POWER_OFF (0x03)
Reply: VCAD_SC_OK (0x00) (in reply to VCAD_EC_POWER_OFF)
Raw reply data: 00
Sending reply...
Waiting for event (power: off, protocol: unknown/undefined)...
</font>>
If someone know how to use this function or have any advice to help me to select a specific protocol with Jcop API, please let me know.
If you you need any more information don't hesitate to ask.
Best regards
Edited by: Cyril on Sep 22, 2011 9:54 AM-1
I'm using a virtual terminal (windows driver), and I don't see how I could turn off the Auto-pps. I've also tried with a real reader and a card and I have the same error.
-2
I've tried value in the range of the atr (based on this analysis: [url http://smartcard-atr.appspot.com/parse?ATR=3b909580811fc7dc]http://smartcard-atr.appspot.com/parse?ATR=3b909580811fc7dc ). But I don't know if only I value of baud-rate is possible in the range. Anyway I just would like to change the protocol, not the baud-rate.
-3
I've already tried to call pps function before, after the first reset, or with another reset later and I always got the same thing.
term = (PCSCJCTerminal)JCTerminal.getInstance("PCSC", readers.get(0).toString().substring(15));
term.open();
System.out.println("\nTerminal opened");
//Getting the ATR
atr = new ATR(term.waitForCard(2000));
System.out.println("ATR: "+toHex(atr.getBytes()));
jcard = new JCard(term,atr,0);
jcard.reset();
try {
term.pps(JCTerminal.PROTOCOL_T0, (int)312500);
} catch (Exception e) {
e.printStackTrace();
}The same pps is always send after each reset... -
Dear Experts,
Please help me in checking why virtual bytes in perfmon is taking more than memory we allocated.
OS
Windows Server 2003 R2 Enterprise x64 Edition Service Pack 2 (build 3790)
ORACLE
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 64-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
Total RAM on box is 8G
Page File
Windows virtual memory equal on C,D,E,F drives is set to 12273M and allocated now is 11262M
LPENABLED is not set
SQL> show parameter pga_
pga_aggregate_target 0
SQL> show sga
Total System Global Area 5344731136 bytes
Fixed Size 2114736 bytes
Variable Size 4630514512 bytes
Database Buffers 671088640 bytes
Redo Buffers 41013248 bytes
SQL> show parameter memory
hi_shared_memory_address 0
memory_max_target 5G
memory_target 5G
shared_memory_address 0
SQL> show parameter sga
lock_sga FALSE
pre_page_sga FALSE
sga_max_size 5G
sga_target 0
Question :
Why oracle.exe is taking 8G virtual; bytes, memroy target can not go beyond 5G. How to minimized the virtual byte in perfmon
Thanks in advance your time and help.John, Thanks for the reply.
Please find the output of query
SQL> select pool,sum(bytes) from v$sgastat group by pool;
POOL SUM(BYTES)
915543216
java pool 67108864
streams pool 268503944
shared pool 2147494008
large pool 67108864
SQL>
SQL> select * from v$pgastat;
NAME VALUE UNIT
aggregate PGA target parameter 671088640 bytes
aggregate PGA auto target 147564544 bytes
global memory bound 104857600 bytes
total PGA inuse 533962752 bytes
total PGA allocated 810819584 bytes
maximum PGA allocated 1244466176 bytes
total freeable PGA memory 90243072 bytes
process count 450
max processes count 588
PGA memory freed back to OS 1.9883E+10 bytes
total PGA used for auto workareas 28210176 bytes
maximum PGA used for auto workareas 39973888 bytes
total PGA used for manual workareas 0 bytes
maximum PGA used for manual workareas 531456 bytes
over allocation count 7
bytes processed 2.6307E+10 bytes
extra bytes read/written 0 bytes
cache hit percentage 100 percent
recompute count (total) 72720
19 rows selected.
SQL>
SQL> show parameter _target
NAME TYPE VALUE
archive_lag_target integer 0
db_flashback_retention_target integer 1440
fast_start_io_target integer 0
fast_start_mttr_target integer 0
memory_max_target big integer 5G
memory_target big integer 5G
pga_aggregate_target big integer 0
sga_target big integer 0
SQL> sho parameter sga_max
NAME TYPE VALUE
sga_max_size big integer 5G -
How to use gui_download 's filetype of 'bin'
Hello,experts ,the detail of my problem as follows:
I use gui_download to download the invoice data :filetype is ASC,the download file is .txt file with tab as the field 's separator.
the internal table:i_khzl :DATA: BEGIN OF i_khzl OCCURS 0, "ITAB OF HEAD INFO.
fpdm(15), "invoice no
tdh(15),
khswdjh(15), "
khmc type TEXT100,
" khmc(100), "customer
khdz(100), "
khyh(100),
bz(100), "
qdhj(1),
jmhj(1),
fphm(18),
END OF i_khzl.
but there is not a Chinese characters like"燊" in the codepage 8400, which result in the customer name display as wrong ,the last byte is '?', and the I download the data using filetype of BIN ,the ? of customer name is gone,but the local file .txt the format is wrong, which the interface of the invocie system can not confirmed.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = g_fname
filetype = 'ASC'
write_field_separator = 'X'
trunc_trailing_blanks = 'X'
"codepage = '4102'
TABLES
data_tab = i_khzl
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE e003 WITH g_fname. "下载文件错误
ENDIF.
the bin download:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = g_fname
filetype = 'BIN'
TABLES
data_tab = i_khzl
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE e003 WITH g_fname. "下载文件错误
ENDIF.
THE CONTENT OF THE LOCAL TXT IS :
ASC:
0491052960 451281672481214 宜州市燊龙贸易有限责任公?
BIN:0491052960 451281672481214宜州市燊龙贸易有限责任公司
the format of the two txt content is different, how to change the bin 's type to asc' type ?or how to use the gui_download function to solve the wrong display of the customer name?
pls help me ,
much appreciated.Dear Pradeep,
Find the below link which explains a simple data download to excel from a table view.
www.sapt echnical.com/Tutorials/BSP/Excel/Index.htm
Try to avoid the way your using in the BSP application and it is abdicable to use the standard methods / class available like "cl_bsp_utility"
Hope this will be helpful.
Regards,
Gokul.N
Edited by: Gokul on Oct 8, 2009 9:57 AM -
How to track no of bytes transferred
Hi there,
how to track no of bytes transferred
while downloading a file using java servlets.
please note that i am not writing any client side application like applet...
Hence I want to track no of bytes transffered to client end from my server (using servlets)
Please kindly help me out as soon as possible.
awaiting the solution immediately.
thanks,
venkat//the following is the code what i have written in my servlet.
res.setContentType(MIME); // I hava parameterised the MIME tag
OutputStream out=res.getOutputStream();
int counter=0;
File f1 = new File("c:/x.pdf");
//int k=(int)f1.length();
fis = new FileInputStream(f1);
byte[] buffer=new byte[fis.available()];
fis.read(buffer);
for(i=0; i<buffer.length; i++)
try
counter=i+1; //getting the number of bytes got transferred
out.write(buffer,i,1); //write to client's directory
catch(IOException ex)
System.out.println("exception while download="+ex.getMessage());
downloaded=true;
if(counter!=buffer.length)
download_error="Not Downloaded";
download=false;
//while executing the above servlet, the servlet prompts for a save as dialog (without file extension, please note I have specified the MIME tag also).
Now the client is entering the file and clicking save
In between he cancels and file is not downloaded to the client's directory.
Now the counter length should not match with the buffer.length, but it is matching exactly and stating that the file has been downloaded properly.
I hope you would have understood my problem.
Also note that I dont have any client side application to monitor the download.
Please let me know how to solve the problem as soon as possible
expecting your reply at the earliest thanks. -
How to use parameter passed from standard page in VO query of custom page
Hi everyone,
I have a custom page which needs to be called from a standard page. Now this custom page is based on some parameters passed from standard page.
How do I catch those parameters i my custom page .
And how to use those parameters in the VO query of my custom page.
Edited by: Bunny on Nov 11, 2010 9:16 AMHi,
Bunny wrote:
I have a custom page which needs to be called from a standard page. Now this custom page is based on some parameters passed from standard page.
How do I catch those parameters i my custom page .---If standard page the button style is :Button,Then u can set Destination URL in personalization.
Destination UR:"OA.jsp?page=/xxx/oracle/apps/po/msg/webui/CustomUpdatePG&Flag=" +Value ---Like u can pass params
---IF the button style is :Submitbutton ,Then u need to customization of the co.
---In co processFormReq call a cutom page like below.
pageContext.setForwardURL("OA.jsp?page=/xxx/oracle/apps/po/msg/webui/customUpdatePG&Flag=" +Value, null, (byte)0, null, null, true, "N", (byte)0);
---In custom page co in processRequest u can get these value :String value=pageContext.getParameter("Flag");
And how to use those parameters in the VO query of my custom page.---Get the vo and set where clause
String where="valueAttr="+value;
vo.setWhereClauseParams(null);
vo.setWhereClause(where);
vo.executeQuery();
Regards
Meher Irk
Edited by: Meher Irk on Nov 11, 2010 11:53 PM
Maybe you are looking for
-
I have rented some movies and have them in itunes. I want to move them to my iphone but don't know how can someone help?
-
Hi, I'm using the 'SALV_WD_TABLE' component. Is it possible to select a column of the ALV by clicking on the column header and initiate an event? Or is it possible to set the header text as a link and define an action for it? Thanks, Anett
-
Setting up connection pool in MSSQL SERVER 2000
hi, i m having too much trouble in setting up connection pool in TOMCAT 5.0.25 for MS SQL SERVER 2000... ......so plz guide me how to do that... TIA bhups
-
Intel Xserve and SCSI Tape Autoloader - Not Being Seen
I have a brand new intel xserve with the added scsi card. I have a sun storedge L9 attached to the system and am unsure how to get the system to detect it. I am sure that the hardware and cables are all compatible. System profiler shows the scsi card
-
Database Expert Links tab work area is missing.
I was forced to give up my perfectly good PC when its lease ran out. When I reinstalled CR XI developer onto my new leased PC everything seemed fine until I needed to edit the links between tables. I can select tables on the Data tab within the Dat