Saving and Loading LineFeed with readLine()
I'm storing mainly text data to a file, but when I save text with line breaks I'm having trouble reading them back in. The line break gets stored as 0x0A as you would expect, but when I use the following code to read the line back in
fin = new FileInputStream (Path);
// Read a line of text
String fData = "";
fData = new DataInputStream(fin).readLine();the data is cut short where the 0x0A character occurs, so I miss everything else on the line. Does anyone know how I can get around this?
Thanks
Here is a sample of the file
<reqdata>
<reqdatatitle>test</reqdatatitle>
<reqdatadesc>Line1Line2Line3</reqdatadesc>
</reqdata>inbetween each Line# is a 0x0A character, denoting the new line. So when I use readLine to get the <reqdatadesc> line all it returns is
<reqdatadesc>Line1what I need is a method of getting the rest of the data so the full line
<reqdatadesc>Line1Line2Line3</reqdatadesc>is returned
Similar Messages
-
Saving and Loading specific properties of an Image
Hey everyone. I'm currently in the process of developing a game which allows you to customize the color (hue) of your character via a slider. What I would like to happen is: Upon clicking either Accept or Play, it will save the current hue of the image, navigating back to that page will load what was previously saved (hue), as well as when starting the game, it will replace the standard graphic with the previously saved image.
Below is the code I have right now that pertains to the image with a basic non-functioning properly saving and loading code:
import flash.events.KeyboardEvent;
// open a local shared object called "myStuff", if there is no such object - create a new one
var savedstuff:SharedObject = SharedObject.getLocal("myStuff");
Accept.addEventListener(MouseEvent.CLICK, SaveData);
PlayBTN.addEventListener(MouseEvent.CLICK, LoadData);
function SaveData(MouseEvent){
savedstuff.data.username = Sliders.Dino.MovieClip // changes var username in sharedobject
savedstuff.flush(); // saves data on hard drive
function LoadData(event: MouseEvent)
if(savedstuff.size>0){ // checks if there is something saved
Sliders.Dino.MovieClip = savedstuff.data.username} // change field text to username variable
// if something was saved before, show it on start
if(savedstuff.size>0){
Sliders.Dino.MovieClip = savedstuff.data.username}
What I have above is only saving the actual image, which is inside a movie clip names Sliders.
Below is the Class I am using that associates with the slider that changes the hue of "Dino".
package
import flash.display.Sprite;
import fl.motion.AdjustColor;
import flash.filters.ColorMatrixFilter;
import fl.events.SliderEvent;
public class Main extends Sprite
private var color:AdjustColor = new AdjustColor();
private var filter:ColorMatrixFilter;
public function Main():void
/* Required to create initial Matrix */
color.brightness = 0;
color.contrast = 0;
color.hue = 0;
color.saturation = 0;
/* Add Listeners function */
addListeners();
private final function addListeners():void
colorPanel.hueSL.addEventListener(SliderEvent.CHANGE, adjustHue);
private final function adjustHue(e:SliderEvent):void
color.hue = e.target.value;
update();
private final function update():void
filter = new ColorMatrixFilter(color.CalculateFinalFlatArray());
Dino.filters = [filter];
Overall what I'm asking for is: How do I get it to save the current hue of an image by clicking a button, and then having that previously saved image be loaded upon reloading or clicking a button? To me, it doesn't seem like it should be too hard, but for some reason I can not grasp it.
Thanks in advance for reading this and for any assistance you have to offer!This is the Class that you told me to use:
package
import flash.display.Sprite;
import fl.motion.AdjustColor;
import flash.filters.ColorMatrixFilter;
import fl.events.SliderEvent;
import flash.net.SharedObject;
public class Main extends Sprite
private var color:AdjustColor = new AdjustColor();
private var filter:ColorMatrixFilter;
private var so:SharedObject;
public function Main():void
color.brightness = 0;
color.contrast = 0;
color.saturation = 0;
so = SharedObject.getLocal("myStuff");
if (so.data.hue)
color.hue = so.data.hue;
else
color.hue = 0;
update();
addListeners();
private final function addListeners():void
colorPanel.hueSL.addEventListener(SliderEvent.CHANGE, adjustHue);
private final function adjustHue(e:SliderEvent):void
color.hue = e.target.value;
so.data.hue = color.hue;
so.flush();
update();
private final function update():void
filter = new ColorMatrixFilter(color.CalculateFinalFlatArray());
Dino.filters = [filter];
And this is the FLA Code:
import flash.events.KeyboardEvent;
// open a local shared object called "myStuff", if there is no such object - create a new one
var savedstuff:SharedObject = SharedObject.getLocal("myStuff");
Accept.addEventListener(MouseEvent.CLICK, SaveData);
PlayBTN.addEventListener(MouseEvent.CLICK, LoadData);
function SaveData(MouseEvent)
savedstuff.data.username = Sliders.Dino.MovieClip;// changes var username in sharedobject
savedstuff.flush();
// saves data on hard drive;
function LoadData(event: MouseEvent)
if (savedstuff.size > 0)
{// checks if there is something saved
Sliders.Dino.MovieClip = savedstuff.data.username;
}// change field text to username variable
// if something was saved before, show it on start
if (savedstuff.size > 0)
Sliders.Dino.MovieClip = savedstuff.data.username; -
My mom helped me to create my iTunes account and load it with a 50$ gift card and now I wanted to purchase a one month subscription at the AYI dating web service but apple never let them take money from my account and I was declined,don't know why?
You have posted to the iTunes Match forum, which your question is not related to. I suggest you contact the web site from whom you wish to purchase the subscription.
-
Cache and Load Balancing with Oracle APEX Listener
Hi,
I intend to use only HTTP access.
How to implement a Cache and Load Balancing with the Oracle APEX Listener?
Is it possible to do with the the standalone running APEX Listener?
Thanks by advance for any tips/documentation/references.
Kind Regards.Hi,
I think this question is best asked in the APEX Listener forum:
ORDS, SODA & JSON in the Database
Kind regards
Sandro -
Saving and Loading variables in a .txt file (Offline)
I'm working a software we've done with Flash, but we'd want
people to be able to save the variables they selected. We need them
to be able to save the value of about 10 variables in a file on
their desktop, and then be able to load that file again.
Is it possible to do that without having to use php or stuff
like that (that's why we want to make it an offline applications so
we don't have to use php to be able to save files).
I know Actionscript looks a lot like Javascript and with
Javascript it's really easy to do, but all the saving functions are
blocked in Flash for security reasons.
If anyone knows how to do that, to simply save and load a
.txt file, please let me know. If it would be possible also to
change the .txt to whatever else it would be even better. The file
can still be opened in Notepad but at least it looks a bit more
professionnal to have our own extension. Again in Javascript or
with a .bat file it's really easy to save variables to whatever
type of file, even to non existing types, it simply creates a text
file with an unknown ending.
Thanks!I found a page that explains in a really easy way how to
communicate with Javascript if the flash object is contained in an
html page, but I couldn't find any page explaining how it works if
it's not in an html page. On our side, before using the software
we're creating we'll convert it to a .exe. How can we call a
Javascript from that .exe since we can't incorporate the Javascript
in the container since there isn't really a container... Is there a
way to link to a Javascript (.js) that would be in the same folder
as the .exe? Or would there be a way to incorporate the Javascript
right into the .exe?
Let me know if any of you have a solution for that.
Thanks!
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Liv eDocs_Parts&file=00000342.html#wp126566 -
Saving and loading images (png) on the iPhone / iPad locally
Hi,
you might find this helpful..
Just tested how to save and load images, png in this case, locally on the i-Devices.
In addition with a SharedObject it could be used as an image cache.
Make sure you have the adobe.images.PNG encoder
https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/images/PNGEncoder.as
Not really tested, no error handling, just as a start.
Let me know, what you think...
Aaaaah and if somebody has any clue about this:
http://forums.adobe.com/thread/793584?tstart=0
would be great
Cheers Peter
import flash.display.Bitmap
import flash.display.BitmapData
import flash.display.Loader
import flash.display.LoaderInfo
import flash.events.*
import flash.filesystem.File
import flash.filesystem.FileMode
import flash.filesystem.FileStream
import flash.utils.ByteArray;
import com.adobe.images.PNGEncoder;
private function savePic(){
var bmp = // Your Bitmap to save
savePicToFile(bmp, "test.png")
private function loadPic(){
readPicFromFile("test.png")
private function savePicToFile(bmp:Bitmap, fname:String){
var ba:ByteArray = PNGEncoder.encode(bmp.bitmapData);
var imagefile:File = File.applicationStorageDirectory;
imagefile = imagefile.resolvePath(fname);
var fileStream = new FileStream();
fileStream.open(imagefile, FileMode.WRITE);
fileStream.writeBytes(ba);
trace("saved imagefile:"+imagefile.url)
private function readPicFromFile(fname:String){
var imagefile:File = File.applicationStorageDirectory;
imagefile = imagefile.resolvePath(fname);
trace("read imagefile:"+imagefile.url)
var ba:ByteArray = new ByteArray();
var fileStream = new FileStream();
fileStream.open(imagefile, FileMode.READ);
fileStream.readBytes(ba);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPicRead)
loader.loadBytes(ba);
private function onPicRead(e:Event){
trace("onPicRead")
var bmp:Bitmap = Bitmap(e.target.content)
// Do something with itAre the movies transferred to your iPhone via the iTunes sync/transfer process but don't play on your iPhone?
Copied from this link.
http://www.apple.com/iphone/specs.html
Video formats supported: H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; H.264 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Baseline Profile up to Level 3.0 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats.
What are you using for the conversion? Does whatever you are using for the conversion include an iPod or iPhone compatible setting for the conversion?
iTunes includes a create iPod or iPhone version for a video in your iTunes library. Select the video and at the menu bar, go to Advanced and select Create iPod or iPhone version. This will duplicate the video in your iTunes library. Select this version for transfer to your iPhone to see if this makes any difference. -
Progressbar and loader problem with IE
Hello there,
well, in my project i have been using the loader and the
progressBar components. (actionscript 2).
the loader and the progress bar placed on the "main.swf" and
its loading an external ".swf's". I am a mac user, so i was testing
the movie on "fireFox" and on "Safari" everything is working well.
but, when i was viewing it on "Internet Explorer" any of the
progress bars didn't appeared and the functions that relates to the
"on(complete)" state, doesn't happen.
if anybody recognize this problem, please leave me directions
to solve this. so frustrating. thanks allot, asi.I can confirm this seems to be a problem for me also. I have
used multiple instances of the Loader component in various sites
recently (AS2) and they all have issues in IE7. I managed to narrow
one problem down to the fact the .progress listener wouldn't work.
I'm having to rip out all instances of the Loader component
and replace it with the MovieClipLoader class as a fix until
someone can shed some more light on this... -
ACE 4710 and load balancing with sticky cookie
Configuring load balancing with SSL termination and stickiness for a couple of citrix xenapp servers. I'm doing a source-NAT as the ACE resides in the DMZ and these particular servers reside on the inside arm of the firewall. The ACE is in bridged mode to load balance web servers that reside in the DMZ. Everything seems to work just fine, but the cookie stickiness does not seem to be working.
Hi David,
As you may know, using Wireshark to look at an HTTPS capture is only useful if you've installed the server SSL key.This is why I find it easier to use something like LiveHTTPHeaders or HTTPWatch.
When using cookie-insert, the ACE will not create any dynamic cookie entries. It will simply create one static entry for each rserver with a cookie value, such as R3911631338, and any client that gets load balanced to that rserver will receive a cookie with that value. So what you see there is what is expected.
You are correct in that when using location cookies that the server supplies, the ACE will create a dynamic entry when it sees the server response with the cookie. The cookie is included in the server's response, and the ACE will look for the value as configured. The cookie will also be sent to the client. If the cookie is not in the server's first response, you will need enable persistence-rebalance so that it will look in subsequent server responses. If the browser opens new connections with that cookie, then the ACE will stick to the same server.
My suggestion would be to get sticky working with cookie-insert first. Then if that meets your needs, go with that permanently. If you need to use server cookies, then once cookie insert is working, migrate your sticky to cookie location.
Sean -
How to speed up my saving and loading of a psd. file?
Hi.
My laptop's 1 TB hdd recently crashed and I replaced it with a 500 GB ssd and Photoshop loads now from 10-12 sec since i re installed Photoshop cc.
Unfortunately, the time it takes to save and load psd files has increased dramatically (I'm comparing it to how it was with my normal hdd). It also, sometimes freezes a bit and then after about 10 sec it unfreezes.
I have looked online for help, but have been unable to find anything that could really help me (or it just went over my head, as I am not very tech savvy).
Any help would be greatly appreciated.
If this has been discussed before, can someone please post the link for me.The rule of thumb I follow to figure out scratch space says to figure on 50 to 100 times the size of your largest file ever multiplied by the number of files you have open. I have seen the scratch file exceed 800 GB once, an admittedly rare occurrence, but it often exceeds 200 GB when stitching large panoramas and the like.
As an example—and stressing that I'm aware that others have even more scratch space than I do—I keep two dedicated, physically separate hard drives as my primary and secondary Photoshop scratch disks and a lot of GB free on my boot drive for the OS. I also have 16 GB of RAM installed.
Additionally, if you only have a single HD, i.e. your boot drive, you'd need it to be large enough to accommodate both the swap files of the OS as well as Photoshop's scratch. -
Liquify Cursor disappears when Saving and Loading Mesh (CC 2014.2.2)
Hello.
I'm using Photoshop CC 2014.2.2 for Mac on a perfectly built hackintosh (Yosemite, i7-4770K, GTX770, Intuos5 L, 32Gb RAM, 2 monitors).
The arrow cursor disappears randomly when dragged over the Save Mesh or Load Mesh dialogues. It's not that the arrow cursor disappears completely. Actually, instead of switching from liquify cursor to arrow cursor as it should, it stays a circle and I can see it behind the save/load mesh window. In order to make the arrow appear in front of the save/load mesh, I have to move it out of it, and carefully move it back in. If I drag the save/load mesh window to an area of the screen clear of the liquify filter window or to my second screen, the problem goes away.
Also, when liquifying, the cursor is a little laggy, like at a low frame rate and behind my pen. I can liquify with no problem, but I can't remember if this is the way the liquify cursor behaves now that the it is GPU accelerated.
All these problems go away if I disable "use graphics processor", but that's a no go for me. I have tried both OS X Default Graphic Driver and NVIDIA Web Driver, but it makes no difference.
Any ideas?
THANKS!I've noticed it happens particularly when the arrow touches any of the text input fields, among other ways I haven't identified yet. The save mesh and load mesh are the only dialogs across Photoshop on which this problem happens.
Notice that the blue cursor drawn by me is where the cursor should be, and note that the liquify cursor can be seen behind the open mesh dialogue. In this case I have to draw the cursor outside of the open window, and drag it back in making sure I don't touch the search field. -
Need help in JAXP - saving and loading of XML
i am new to JAXP so dunno how to write the codes to save and load a hub project to and from an XML stream ...so can any one help by posting some codes to guide me alonr... will be grateful to u...this is wat i have done ,can anyone help to complete it ..thank...urgently
import java.util.*;
public class Testvector
private Vector m_vProcess;
String strProjectName;
public static void main(String[] args)
TestVector pThis = new TestVector();
pThis->WriteToXML(m_vProcess);
public TestVector
strProjectName ="Project1";
m_vProcess = new Vector();
m_vProcess.add("Process1");
m_vProcess.add("Process2");
public void WriteToXML(Vector vProcess)
//JAXP
//write project element with attribute name
//iterate through all the elements in vector m_vProcess
//write process elements with name.
<?xml version='1.0' encoding='utf-8'?>
<!-- project -->
<project>
<!-- process -->
<process type="all">
<name>1st</name>
</process>
</project>
can any one help?Choose Xerces2.4 to serialize the DOM object is an option.
javac XercesTest.java -classpath xmlParserAPIs.jar;xercesImpl.jar;.
java -classpath xmlParserAPIs.jar;xercesImpl.jar;. XercesTest test.xml
below is the source file: XercesTest.java
//JAXP
import javax.xml.parsers.*;
import org.w3c.dom.*;
//APACHE SERIALIZE FUNCTION
import org.apache.xml.serialize.*;
class XercesTest
public static void main(String[] args) throws Exception
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse( new File( args[0] ) );
File f = new File( "copy_of_"+ args[0] );
OutputFormat format = new OutputFormat("xml","UTF-8",true ) ;
FileOutputStream fout = new FileOutputStream( f );
XMLSerializer ser = new XMLSerializer(fout, format );
ser.serialize( doc );
maybe it's helpful
land -
Saving and loading plugin's settings by using SDK APIs.
Hi All.
I am trying to save and load plugin's settings, ex. dialog setting values and strings.
OS platform is windows XP.
First I programmed the way of using *.ini file.
But that not appropriate for Macintosh.
So, I like to know common way by using SDK's APIs.
Development env. is VS2008 and Ai CS5 SDK.
Thanks.Use AIPreferenceSuite (AIPreference.h)
-
Saving and loading control properties
Quick question,
Does anyone know of an "easy" way to save and load pre-defined appearences or "skins" for controls and indicators?
I had hoped LV 8.0 did this in the property explorer, but having just checked it out, it doesn't seem to.
I basically want to be able to define the appearance of indicators (XY
graphs particularly) based on calling up either ini files or otherwise.
I want to avoid writing a cumbersome cluster-based read and write
routine for each and every type of control (Split into classes of
course, but still.....)
Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)Thanks tst
I will add the link to my labview folder. The property saver will be a useful feature and would be a great method to have added to all gi objects, like Gobject->SaveState(file) and Gobject->LoadState(File), this could be polymorphic and also include versioning information and even allow for some metadata about the object. Here you could make skins of a vi and it would save all the objects in a standard form.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA -
Saving and loading 1D array to/from file
Hi,
i have some problems with my NI application. for the first, i have case structure with two cases: true and false.
FALSE: in this case i have a for loop with 100 samples. i catch signal from my DAQ (now just Simulate Signal) and what i want is to save it in a 1D array and at the end of the loop the COMPLETE array into one text file. Problem in my vi: just the values from the last iteration are saved.
TRUE: now i have while loop. AT THE BEGINN of the loop i need to load my array from the file and not in the middle of the loop. Why? The data from the file are needed during the loop.
thanx in advance
Vedran Divkovic
RUB GERMANY
Attachments:
Regelsystem.vi 1494 KBAccording to your code, what you are saving is an array of means (one from each iteration), and NOT the last iteration. If you want to keep the entire data, it would be a 2D array.
Why are you generating an entire waveform at each iteration? Shouldn't you just generate one point?
LabVIEW Champion . Do more with less code and in less time . -
SFE2000 saving and loading configuration
I have a number of SFE2000 10/100 24 port POE switches.
They are configured and running OK. I want to be able to save the configuration and be able to load that saved configuration into another new swich in the case of a failure.
I have logged in and gone to Admin-File Management-Save Configuration. I then select the 'Backup' radio button and TFTP the configuration to my TFTP server. All works OK and I have a readable text file with the switch configuration on my TFTP server.
Now, here comes the problem.
I want to be able to restore that saved configuration on to a new switch.
I have set the new switch back to factory defaults. I go to Admin-File Management-Save Configuration. I then select the 'Upgrade' radio button and try and uploade the file into the switch.
If load to 'Running Configuration' the switch shows a status of 'Copy Finished' but says 'Copy completed with errors'
If load to 'Startup Configuration' the switch shows a status of 'Copy Failed' and says 'Copy completed with errors'
Am I missing something here???
I am guessing I should be able to load my saved Configuration back into a switch, shouldn't I??
And yes the switches are running the same firmware 3.0.0.17
Any help gratefully received. I am scratching my head here...
AlanHi Alan,
Thank you so much for your feedback.
When copying over TFTP, is there another error message following the described : %COPY-W-TRAP: The copy operation has failed ? I would suppose that at least a second message would be logged with the reason for the failure.
As far as the transfer of configuration files is concerned, it is always safer to make sure the FW versions of both devices are the same. As far as upgrading is concerned. Switches that use the older fw version 1.0.0.x need to be upgraded to 3.0.0.17 first using the easy upgrade utility. Switches with HW version 2 and FW version 2.x should be upgraded using the regular TFTP or HTTP method (not the easy upgrade utility). All of this can be read in the release notes for fw 3.0.0.17 and 3.0.0.18
As far as Xmodem is concerned, you make the connection to the switch using Hyperterminal, TeraTerm Pro or any other terminal emulator supporting Xmodem, when booting the switch, you can escape the boot sequence (given the switch does not boot up) by pressing Esc or Enter when this appears on the screen. You'll then have an option to "Download Software", select this option. Then on your terminal emulator, select to transfer file (send) using Xmodem. This should do the trick.
Hope this helps,
Best regards,
Nico Muselle
Sr. Network Engineer - CCNA
Maybe you are looking for
-
Hi experts , in alv report
in alv report i need to display the different customers in different blocks in the alv output, for example customer : 1000 in one block with all the details , and customer : 10001 in other block in the same alv , if possible provide the coding. its v
-
BPM - Status always in "In Process"
Hi Experts, I have implemented a simple BPM for a Message Split pattern - where the source message will be split into 10-2000 messages. And these messages are sent to target system using a ForEach block with Send step. I'm facing two problems here...
-
Disc drive makes strange noises
I just got my macbook and from the very start whenever I insert a disc it makes a noise like its popping and breaking internally. the disc will play fine, but the sound is SO wrong that its worrying me. Has anyone else had this problem? Was it just s
-
Assistant downloaded. I was very confused as to where to cick on the directions; I did see the notice " 30 days remaining." I must have clicked "buy" because it asked me for a serial number. I backed completely out, even trashed Assistant. I lef
-
Pls help those anyone to how to reset the security questions I know my emails addrs and password when I purchased the apps there is a additional or security question appears in the screen so pls help me apple company how to out this coz I bought new