Read/Write ints using 2bytes
Hi. I was wondering if anyone can help me read and write one interger using two bytes. I have an interger between 500-800 that I need to write. Normally I would use...
OUT.writeByte(int)
But as 500 is above one byte (256) I was wondering how to write this, and then later read it back.
As since one int would be spread over two bytes, I have no idea how to read it, normally I would use
IN.readByte()
And I have no idea how to do this. Can anyone help me please?
You were told how to do this using individual bytes in your other thread here:
http://forum.java.sun.com/thread.jspa?threadID=576927&tstart=0
If you don't know how to write the code and are not willing to use the Java Tutorial to learn how to do it, then write it as a short, which is 2 bytes.
(You write the code, we comment on the problems, not the other way 'round)
Similar Messages
-
Asynchronous read & write by using Asynchronous api provided in nio-java 7
HI,
I am trying to write a small program to implement **asynchronous read & write by using Asynchronous api provided in nio in java 1.7** in windows machine.
i tried the following code to write a small string to a file asynchronously.file is getting created but the contents are not dispalying.
static long startTime = System.currentTimeMillis();
static long endTime;
static long execTime;
public static void main(String[] args) {
String path = "C:\\AsynchWrite.txt";
Path file = Paths.get(path);
final AsynchronousFileChannel channel;
long pos = 1;
try {
OpenOption[] options = { StandardOpenOption.CREATE,
StandardOpenOption.WRITE, StandardOpenOption.SYNC };
channel = AsynchronousFileChannel.open(file, options);
ByteBuffer buffer = ByteBuffer.allocate(1000);
String writeThis = "Testing by writing a line";
byte[] src = writeThis.getBytes();
buffer.put(src);
channel.write(buffer, pos, null,
new CompletionHandler<Integer, Object>() {
@Override
public void completed(Integer result, Object attachment) {
System.out.println("completed successfully");
System.out.println("start time :" + startTime);
endTime = System.currentTimeMillis();
System.out.println("end time : " + endTime);
execTime = endTime - startTime;
System.out.println("Execution Time :" + execTime);
System.out.println("Execution Time(ms) :"
+ execTime);
try {
channel.force(true);
channel.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@Override
public void failed(Throwable exc, Object attachment) {
// TODO Auto-generated method stub
System.out.println("failed!!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}Please help me out
Thanks in advance,
RaviIt looks like you are missing buffer.flip() after your put as otherwise the buffer position will be at 25 (not 0 as you expect).
-
Unable to read/write bytes using 9870 with cRio 9151
Hi everyone,
I'm currently having some problems trying to use 2 ports of module NI 9870. I'm unable to read bytes even if I try to send some datas (I always get a Timeout) and I'm also unable to write some datas( I can't see nothing on Hyperterminal).
Please find enclosed a snapshot of my Fpga code.
Regard,
Nicolas Kaminski, Toulouse France
Attachments:
ReadBytes.jpg 93 KB
WriteBytes.jpg 30 KBHello,
Can you give us some other details:
Are you sure that you provide power to the 9870 module?
Do you have tested your system with an example? (NI-987x Serial Loopback.lvproj)
DO you get something through that loopback?
Regards,
Mathieu P. | Certified LabVIEW Associate Developer
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
Journées techniques : des fondamentaux aux dernières technologies pour la mesure et le contrôle/comm... -
Read/write keywords using applescript and iMagine Photo
Does anyone know if applescript & iMagine Photo are capable of reading/writing to the IPTC keywords?
I can't seem to figure it out. I use
{exif type:info, exif unicode:gImageInfoText}}
to modify description ({exif type:info, exif unicode:gImageInfoText}) field of the IPTC data but can't understand how to write to the keywords field.
Does anyone know to simply read the keywords form the IPTC data?
Thanks.
PedroYou could install [ExifTool|http://www.sno.phy.queensu.ca/~phil/exiftool>, and then use “do shell script” commands such as in the following examples:
*do shell script "exiftool -keywords=AppleScript -keywords=\"iMagine Photo\" -keywords=IPTC ~/Desktop/myPicture.jpg"*
--> " 1 image files updated"
*do shell script "exiftool -keywords ~/Desktop/myPicture.jpg"*
--> "Keywords : AppleScript, iMagine Photo, IPTC"
Message was edited by: Pierre L. -
Read/write problem with Datasockets.
Hi, I'm a newcomer to Labview, and I'm having a problem with Datasockets. When trying to create a 'Publish & Subscribe' socket between two machines it only works on one, the one whose dstp address is the local machine, the other being incapable of writing to this 'host' and displaying red LEDs, although it is reading from the host. Also I've only managed to set up these read/write connections using the right-click options, how is it done programatically? Any clarification on the issue (whether directly connected or not :-) would be appreciated. Many thanks,
TomHi Lector!
This is normal behavior for DataSocket. You want to run a DataSocket server on both machines. Although you can SUBSCRIBE to a DS server anywhere on the network, you can only publish to your local server. We do a LOT of Datasocket work here, and this has never been a problem. It's a real security bonus, as well.
It's a good idea to split all your read and write functions. Although some front panel objects (knobs, particularly) can be controls and indicators simultaneaously, it's good practice, for a number of reasons, to NOT use both functions. I build "dummy" front panels for all my VI's which I distribute to all my colleagues who need to work with a remote instrument.
You cannot really appreciate DataSocket, till you've tried to rem
otely control something with PC Anywhere over a slow network! A bit of practice, and you'll wonder how you ever did anything without DataSocket. I'd be glad to work with you on any particulars. Good Luck!
Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705 -
When I move a folder from an external hard drive to the internal hard drive on my laptop, all the files and folders become read only. It is very annoying to change hundreds of files to read/write for use with Word or Photoshop and other applications. Just changing folder permissions does not change the internal files. Is there a general solution to this problem?
http://en.wikipedia.org/wiki/Filesystempermissions
Files on a Web server are a lot different than "local" files. On your Mac you have a "User" account and only you have access (assuming you've set a password for log-in at that account).
The files found on a server (MobileMe or any other) would be uploaded by "you" and access to those files is also password protected. If your password could be found anyone could modify or delete your files because the server wouldn't "know" it wasn't you that authorized those changes.
This is a lot different than the Unix file system permissions used in OS X. Since you could have dozens of User accounts then each of those accounts could access the iWeb application. But they couldn't modify any file stored in an other User's "Home" folder (where the iWeb package file is kept).
Apple servers could access your files stored or served from your iDisk. It's part of the terms of use agreement that you allowed when you signed up for the service. This is an entirely different version of file "permissions".
I may not have explained this in the best fashion or skill. Others are free to chime in. -
How to programmatically read/write the range of a fieldpoint AI channel using LV
Is there a way to programmatically read/write the range of a fieldpoint AI channel using LV ? The example on NI site only permit you to have the name of the device and channels, not the actual set of the range of measure. Anybody has a VI (LV5.1 please)to share?
Thank you very muchIf you are using the FieldPoint VI's (Open, Create Tag, Read, Write, Advise), you do not have the ability to change the range of a channel. If you have a FP-1000 or FP-1001, you can use the Optomux commands as described in the FP-1000/1001 Programmers Reference Manual (FieldPoint Optomux VI's are available at ftp://ftp.ni.com/support/fieldpoint/LVFPOpto/ ).
Alternatively, if you have an ethernet network module and LabVIEW 6i or later, you can use the ethernet configuration VI's that ship with FieldPoint Explorer 3.0.1.
Regards,
Aaron -
Using javascript to call a signed applet's read/write functions problem.
Hi, I wan't to use javascript to call the read/write functions of my signed java applet.
The applet can read/write fine, if its called from inside the applet, but when I make public functions to do the read/write and then call those functions from javascript, i get the old security exception.
Has anyone done this before?
ThanksFrom what I understand is that for example file IO can only be done if the current method
has this privilege and the stack that called the current method had this privilege.
Javascript doesn't have any privilege and calling methods that do file IO directly from
javascript should not work, this bug was fixed in 1.4.2.
The workarround AccessController.doPrivileged(new PrivilegedAction() { might allso be
fixed in later versions since changing the privileges of currently executing code is
someting that should not be possible when the currently executing code is called from
"untrusted" (javascript) code.
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post -
I have adobe acrobat 11 reader writer I want to use the pointer symbol on full screen instead of the hand, iwas able to do it on adobe 10 also when in full screen i can't open attachments unless i right click and open it then it boots me out of full screen is there any way i can click on the attacment without going out of full screen
I don't know why the change, but the pointer appears in the same way as it does on the main screen, not a pointer. There does not appear to be anyway to change it. You may want to submit a comment to the Features Requests: Acrobat Feature Requests. I also submitted this as a bug.
As a clarification, your "adobe acrobat 11 reader writer" is not informative. There is Acrobat 11 and Reader 11. Writer is not a product as such. So you have referred to Acrobat in a contradictory manner. In the future, please just indicate Acrobat 11 or Adobe Acrobat 11. -
Unable to access only Read Write addresses of AB Micrologix 1400 PLC using NI DSC and NI OPC server
Hi,
I have been using NI DSC and OPC servers (NI and Kepware) to communicate with Allen Bradley Micrologix 1400 PLC (1766-L32BXB). Recently at one site I found that I could access Process values from the PLC correctly (Read Only tags) but could not access the Read Write Tags at all. The latter are addresses to which it should be possible to write Set (i.e., references) values from MMI or PC software. I am able to do so from the MMI not from the PC software. I get communication error message on the MMI and PC, mentioning the PLC address being accessed (e.g. N7:0).
Support from the supplier is not available. Hence can anyone let me know if ladder logic could have been written to prevent PC software based access of Read/write addresses (N7:0 to 9 in this case), while permitting access to Read only addresses? Is the problem at the PLC end or OPC server end? Is there a way to get around this?
Thanks in advance.The OPC Server cannot force Outputs so if th registers in question are the outputs of ladder rungs you cannot write to them via the server. The controller will accept the write from the server but will not execute the write. In some cases the server event log will post an error if it is the PLC. Do you get errors when you try to write and if so what are the posted error messages.
Fred Loveless
Kepware Technologies
http://www.kepware.com -
Read/Write pdf's as blobs using forms 10g
Hi All,
I have a table called IMAGES in which i store the pdfs as blobs.
It was successfully working fine with me when I was using forms 6i.
Recently I installed oracle 10g and just found that 10G doesnt support OLE.
I came to know about WEBUTIL package and I have already included in the form.
Could you please help me out how can utilize this WEBUTIL package to read/write blobs from database.
If you have already developed any code like that, could please forward me?The WebUtil_file_transfer.client_to_db and db_to_client will give you direct access to read and write to the blob - I think the Demo form on
http://www.oracle.com/technology/products/forms/htdocs/webutil/webutil.htm
has an example of this -
Can I use a USB superdrive DVD reader/writer with a mac pro?
The internal CD/DVD read/writer in my macpro (2 x 2.66 ghz dual-core xeon) broke, so I purchased an external USB superdrive, thinking I could use it as an external drive. It does nothing when plugged into the mac pro, I cant even insert a disk. It seems to not even have power.
Anyway I now see the device (superdrive) is intended for a macbook air or mac mini.
Am I toast? Is there no way I can get this thing to work with the mac pro?
I dont think I can return it, I've already discarded all the packaging.
Thanks for any advice.I agree it would not take a lot of time, 2 minutes perhaps for the world record holder, for me more like 10 perhaps, not including the time involved in purchasing the drive, figuring out how to recycle the old broken one that comes out, etc.
However the key point is that if I can get this drive to work, the cost will be $0, as I've already paid for it. So I would be most interested in doing that, if possible. If it's not possible, then I'll have no choice to pay $30 or however much, for a new one. -
Deliver file with read/write properties on target side using receiver file
Hi All,
Our file-to-file scenario works fine. By default, PI creates file on target directory with the 644 permissions. Files coming inbound from PI are not read/writable to the group. Currently the files from PI are coming across with 644 permissions and they should be 664 or 660. Is there a way to generate read/write files on targer side using SAP PI??
Thanks in advance,
- Riya PatilHello,
Try using Run-Operating system command after processing parameter with the below mentioned command:
chmod 0755 /usr/sap/tmp/test/*
where: /usr/sap/tmp/test/ is the directory path location.
Br,
Rahul -
Read/Write using single adapter
How can i move the files from one location to another location using single file adapter?
Adapter can have only one operation either of the below.
Read, Write, Synchronous and Listing
To move the files you can refer the below URL and navigate to the below topic
http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CIACJFHF
*4.5.11 Copying, Moving, and Deleting Files*
- It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts).
Thanks,
Vijay -
When starting Final Cut Pro 7.0.3 I am all of a sudden getting a message that says "One or more of the scratch disks don't have read/ write access" and now the app won't operate - how do I fix this so I can use Final Cut Pro?
Glad you found the answer. But something seems wrong. FCP should be able to assign the scratch disk to your startup drive. It's not advisable, but it should be possible. You might want to try and figure out what's going on before what ever's going on cause other problems.
Maybe you are looking for
-
Stacking Images and Ratings: Bug or Feature?
So, I went through my main library of images (7000+ NEF Raw files), and applied Star Ratings to some of the images, several(50+) of those got 5 stars. Later, I got the idea that it would be good to manually stack most of the images into what I would
-
There's a constant noise coming from the fan that I didn't have on my older macbook.
-
Oracle Retail Integration - Partner Oracle Object
Defect 13014494 has been created via Defect Workbench iBug portal request id: (3095192). Fix is ready for QA and will be released in RIB 12.0.11.4 bundle, expected by 31st Jan 2012. In version 12.0.11: The Oracle Object for partner CreatePartnerRibOb
-
Hi, I need to figure out BAPIs for Retrieve products for a given product category in a given catalog Retrieve suppliers for a given product category Please let me know. Thanks
-
Plant and shipping point have no connection but still order got created.
Hi All, An order was created and subsequenty delivered and invoiced. Later on the goods were returned. The problem which occured is that the return order have plant A and shipping point B, which are in no way connected to each other. There is no con