Can somebody help me in ByteArrayinputStream read(Byte[]) is not blocking.
I am setting String "User" in inputStream now Once it is read and inputsteram is blocking for other input i want to send
another strign in input Stream i.e "password" so first "User" will print and then it will print "Password", but ins.read(buff) method is not blocking and returning -1 after reading "User".
Following is the program:
package abc;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class InStream {
InputStream in;
String value;
boolean flag=true;
Inner inc;
InputStream getInStream() {
ByteArrayInputStream bais = new ByteArrayInputStream(value.getBytes());
return bais;
void setValue(String value) {
try {
this.value=value;
} catch (Exception e) {
void execute() {
try {
setValue("User");
inc = new Inner();
inc.start();
Thread.sleep(10);
setValue("Password");
inc.ins=getInStream();
} catch (Exception e) {
e.printStackTrace();
class Inner extends Thread {
InputStream ins;
public void run() {
try {
int retRead = 0;
byte[] buff = new byte[2048];
String receivedStr=null;
ins = getInStream();
do{
retRead = ins.read(buff);
receivedStr = new String(buff, 0, retRead);
System.out.println(receivedStr);
}while (retRead>0);
System.out.println("Out");
} catch (Exception e) {
e.printStackTrace();
public static void main(String[] args){
InStream instream=new InStream();
instream.execute();
}
You create that byte[] input stream once and use it to read its contents into a large buffer. So it is read to the end at the first time, and the next reading will indicate the end.
What is the problem?
ins = getInStream();
do{
retRead = ins.read(buff);
receivedStr = new String(buff, 0, retRead);
System.out.println(receivedStr);
}while (retRead>0);
System.out.println("Out");
} catch (Exception e) {
e.printStackTrace();
}
Similar Messages
-
Can somebody help?what do i need to do if my iphone is not charging using the USB and other adaptor..please help me...
if it's not charging both using usb and ac then likely it have a broken connector or defect battery
if it works on the ac charger then you need to get itunes working on the computer as that seem to be required for a computer to charge an ios device -
after updating my iphone 3gs from os 4 to os 5.1.1, it left with activating the phone but i've been trying since and is still not activating, the notification given is ''activition server temporarly unavilable". can somebody help me out?
First use JPanel not Panel.
Panel panels[]=new Panel[4];becomes
JPanel panels[]=new JPanel[4];Then refactor your code so that you use arrays correctly:
panels=new Panel();
panels.setLayout(new FlowLayout(FlowLayout.LEFT));becomes
panels=new JPanel();
panels[i].setLayout(new FlowLayout(FlowLayout.LEFT));
I did the above changes to your code and it worked fine.
Dave -
I have an external hard drive, from Iomega. that I can open and see my files. However, I cannot copy or save any file to it. On my PC I have it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?
Also, Im a photographer, so I like to name a lot of files at the same time (used to do in on PC and it was very usefull.) cannot find out how to do it on my Mac. Really appretiate if some one can give me a solution! ThanxYour drive is formatted with the NTFS file system. OS X can read but not write to the NTFS file system. There are third party drivers available that claim to add the ability to OS X to write to an NTFS partition. I have not tried them and don't know if they work.
The only file system that OS X and Windows can both write to natively is the FAT32 file system. -
Hey I have a movie that plays on AVI format but my laptop is not reading it. it says that is missing a codec and cannot be read. can somebody help me please
Luigi1990 wrote:
Hey I have a movie that plays on AVI format but my laptop is not reading it. it says that is missing a codec and cannot be read. can somebody help me please
Try installing VLC Player for Mac
http://www.videolan.org/vlc/download-macosx.html
Cheers
Pete -
Can somebody help me in finding a solution or an explanation to the problem I am currently experiencing as well as others wherein we cannot connect to the iTunes store. An error message appears and either says "iTunes could not connect to the store. An unknown error occurred (0x80096004). Make sure your network connection is active and try again" or "iTunes could not connect to the store.Make sure your network connection is active and try again." Despite the fact that my network connection is working quite fine, this problem still persists. I can say that my connection is fine because I can surf the internet and furthermore, I used to connect to the iTunes store just before this incident happened which started from April 17, 2014 and persists until today. I tried to solve the problem by following the troubleshoot procedures given in the support section of this site but it really did not solve the problem. I believe that others are experiencing this situation as well very similar to mine when it comes to the time of occurrence as I have read in the discussions in this site. Even though we have different network connections, operating systems and other specifications, we still experience the same problem, so is there really a problem with our computers or is it with the iTunes? And by the way, my computer works under Windows XP. Thanks a lot. God bless.
Try this...
Triple click anywhere in the line below to select it and press Ctrl+C to copy it.
cmd /k netsh winsock reset
Press the WinLogoKey+R to open the run dialog, then Ctrl+V to paste, then press enter/return.
You should get something similar to this:
Reboot the computer and the problem should be resolved.
If it doesn't work then perhaps a full tear down and rebuild of iTunes will fix things. See Troubleshooting issues with iTunes for Windows updates for details.
tt2 -
I am new with iMac and I am trying to copy some file from my external HDD that a used with my PC but it does not let me also I can't delete anything from this HDD using the finder. Can somebody help me , please?
No, unfortunately, when you format a drive, it will erase all the contents. So you will need to find a temporary "storage" place to put the stuff using a PC so you have access to it. Then reformat using Disk Utility (Applications > Utilities). If only using with mac, format Mac OS Extended (Journaled) and use GUID Partition scheme under Partitions/Options. After formatting, you can drag the files back.
-
Hi there everybody,
My new Iphone 5 uploaded doubleded all the songs from my library! Please, can somebody help me showing how can I delete just the songs that was doubled?
Some help will be greatly appreciate.
Thanks much!When you say "account," do you mean your iTunes library, because your iTunes library is what is on your computer? Your iTunes library does not have an email address. An account that is related to iTunes is your Apple ID (which is an email address) and you use it as your user name to sign in to the iTunes Store, to make purchases. Changing your Apple ID will not make songs disappear from your computer's iTunes library.
If you had an Apple ID and used it to make song purchases from the iTunes Store, and then started using a different Apple ID, you should be able to re-download the songs purchased with the old Apple ID. In iTunes, sign in to the iTunes Store using your OLD Apple ID (and password). That may not be your current email address, but Apple uses it as your user name, so it does not matter.
On the iTunes Store Home screen, click on Purchased under QUICK LINKS. This takes you do the Purchased screen, where you can re-download previous song purchases (for that Apple ID) at no cost.
NOTE: If those song purchases are from more than a few years ago, you may also need to authorize your computer to play (and sync) songs for your old Apple ID.
For songs that were not purchased from the iTunes Store, if they are also gone, you cannot get them back unless you have a backup (or they are still loaded on your old iPod).
If that's not what you mean by "changed the email address on my account," please post back with more details. -
I can´t sync iCal events written in the iphone4 to the macbook ical, but conversely from macbook to iphone there´s no problem, can somebody help me?
Thanks for your answer! I tried as you say, erase the Sync History, but now does not sync any calendar, only displays the birthday ...do not know whatelse to try.
-
Can somebody help with the error message ce_copy_not_allowed when transfering books to my NOOK
I have the same problem HELP Not computer savvy Using a kobo glow have purchased the books from the kobo store. using adobe editions 4 and my computer is authorized.
-
My account was deleted for security issues. I made a new account, but I can't syncronise my apps with this new account. I bought a new Iphone and would like to transfer the apps ans music on this new one. Can somebody help me?
Why would you make a new account? This will likely cause many problems. Just get you old account enabled.
Apple ID: "This Apple ID has been disabled for security reasons" alert appears
Frequently Asked Questions About Apple ID
Everything you purchased with the old account will always be tied to that account. You will have to authorize the computer for that account and you will have to update the apps from that account. -
I installed Mountain Lion in my IMac and now, some times, when I start up my mac it looks with a black screen and white text. I'm really worry about it, can somebody help me?
Don't worry, this is probably just Verbose Mode. It's perfectly harmless. If you're not specifically invoking it, than it's probably down to an unwanted setting in NVRAM. See this article on resetting NVRAM if it continues to bother you.
-
When opening Itunes, after placing my ID and password, I'm getting a message that indicates "Itunes has stopped working. A problem caused the program to stop working. Windows will close the program and will notify you if a solution is available. But I never get a response. Can somebody help?
Same exact thing with me. And no help from apple. Just dropped nearly $600 and cannot get a decent working setup.
Apple's only suggestion was to uninstall iTunes and Quicktime, and re-install... of course (the I.T. Crowd tactic).
The crash happens only on iTunes store access. -
iTunes tells me, that I need to load version 11.1 in order to load a backup into my iPhone 5. I'm working with a windows PC and want to update my phone to iOS 7GM. version 11.0.5 is the highest I can get for windows. Can somebody help me?
I'm assuming you followed a forum like Gizmodo to load the latest version of iOS 7 Beta on your device
Alot of those forums forget to mention, iTunes 11.0.5 will allow you to update to the iOS 7 Beta but your device will no longer work unless you have the developer version of iTunes as well....
I'd suggest you to research how to downgrade back to 6.1.3/4 and wait a few days for the iOS to be released, -
I bought a iTunes card last month in Lax but can't redeem it while in Malaysia can somebody help me
I bought a iTunes card last month in Lax but can't redeem it while in Malaysia can somebody help me
A card purchased in LA would be in US currency. Is your AppleID set up for US or Malaysia? If it is not US, you will not be able to use it.
Maybe you are looking for
-
How to Read from multiple channels
Dear Sir I am acquiring data using FP-RTD-122 using OPC Client software. I ahve made one socket for that and i am using command CWDataSocket1.AccessMode = cwdsReadAutoUpdate CWDataSocket1.URL = "opc://localhost/National Instruments.OPCFieldPoint/FP R
-
Volume Slider not working in DV6-2150US
I have HP Pavilion Notebook DV6-2150US, Win 7. Just discovered a few days ago that the volume slider and quick launch mute button stopped working. I searched the old posts but don't know if this relates to other issues mentioned.
-
Since upgrading from Leopard to Snow Leopard, Frontrow now plays the videos very Jerky. Irregardless of downloaded digital content from iTunes or a DVD. Can anyone say if they have the same problem or a reason why this may be occurring on my machine?
-
How to use a collection in ADF
Hi all, How to use the collection in ADF. Thanks in advance C.Karukkuvel
-
I've been using my BT youview box connected to my Panasonic TV with the BT supplied HDMI cable successfully for several months. But for the last two weeks I've encountered a variety of problems e.g. Box locks up and will not respond to remote control