key « Development « Java I/O Q&A





1. Java NIO select() returns without selected keys - why?    stackoverflow.com

In writing some test code I have found that Selector.select() can return without Selector.selectedKeys() containing any keys to process. This is happening in a tight loop when I register an accept()ed ...

2. How do I programmatically import a public key .cer file into a java keystore using JSSE?    stackoverflow.com

I want to take a public key .cer file generated from java keytool command like this: "keytool -export -alias privatekey -file publickey.cer -keystore privateKeys.store" and import it into a new, empty java ...

3. How to read key=value file and how to split a comma-separated String?    stackoverflow.com

I made a config file it has some following format

variableName = value
variableName = value
variableName = value
I know I can read file split them store them in variable. But I am looking ...

4. Use class name as root key for JSON Jackson serialization    stackoverflow.com

Suppose I have a pojo:

public class MyPojo {
    int id;
    public int getId()
    { return this.id }

    public setId(int ...

5. Java Selector select() always returns the last read key    stackoverflow.com

I am trying to write a TCP server that reads data sent by the client. I want to keep the client connection open after the read to be able to read ...

6. How to Load RSA Private Key From File    stackoverflow.com

I am working on a test harness for a SAML 1.1 Assertion Consumer Service. The test must generate a signed SAMLResponse and submit it to the ACS encoded in Base64. ...

7. How to convert .pfx file to keystore with private key?    stackoverflow.com

I need to sign Android application (.apk).
I have .pfx file. I converted it to .cer file via Internet Explorer and then converted .cer to .keystore using keytool. Then I've tried to ...

8. How to read public key from PFX file in java    stackoverflow.com

I am able to read private key from PFX file but not public key. I am using following code to read public key.

InputStream inStream = new FileInputStream(certFile); 
CertificateFactory cf = CertificateFactory.getInstance("X.509"); ...

9. What are the key points to make sure while implementing serialization    stackoverflow.com

What are the key points in checklist to be checked while implementing good serialization in java (I'm not really looking for , implements Serializable, write, readObject etc). Instead , How to reduce ...





10. How to encrypt a file in java using AES    stackoverflow.com

I need to know how to create an AES and using it to encrypt and decrypt a file in java.

11. What is the default behaviour of a selector when the key set is sized 0?    stackoverflow.com

Just wondering what the normal behaviour of a Selector in Java is when the key set is 0, since it's essentially a pointless operation (no keys available for selection). ...

12. exchange of public key as a serialized object    stackoverflow.com

How to exchange the public key to the client place. i have encrypted a document(text file) using RSA algorithm by using private key and then stored the public key as an ...

13. Java symmetric key file generation and use    stackoverflow.com

I'm working on a school homework, in which I'm sending files from one host to another. As a part of it, I need to encrypt the files being sent using symmetric ...

14. problem reading a publickey file and use the key to encrypt another file    stackoverflow.com

I've been strugling with reading a publickey file which I want to get the key sting in the file and use it to encrypt another file. I'm using RSA PKCS1 v1.5 ...

15. How to use .key and .crt file in java that generated by openssl?    stackoverflow.com

I need asymmetric encryption in java. I generate .key and .crt files with own password and .crt file by openssl that said in http://www.imacat.idv.tw/tech/sslcerts.html .
How to use these .key ...

16. Getting RSA private key from PEM BASE64 Encoded private key file    stackoverflow.com

I have a private key file (PEM BASE64 encoded). I want to use it else where to decrypt some other data.Using Java i tried to read the file and decode the ...





17. Java: nio WatchService - Can't detect second file creation. Why?    stackoverflow.com

i am trying to detect file creation in a folder but WatchService can't detect second file creation. it stucks at key = watcher.take();. Any idea why? I am using Ubuntu 11.04 ...

18. SSHJ Example of Public Key Auth from File    stackoverflow.com

Can someone give me an example of using SSHJ for Public Key Authentication? I realise this question is essentially identical to sshj example of private/public key authentication, however the answer ...

19. In IntelliJ IDEA, how can I create a key binding that executes a shell script with the current file as a parameter?    stackoverflow.com

In IntelliJ IDEA, how can I create a key binding that executes a shell script with the current file as a parameter? For exanmple, if I am in a test file (entity.spec.js), ...

20. listening to two keys simultaneously    coderanch.com

i have written a key listener for the keypressed event. the problem is that when a key is pressed and held the listener does not respond to any other key pressed. i want different keys recognized independently and simultaneously.how should i use multithreading and event handling in this case? kindly note that i am using awt package in an applet. waiting ...

21. Switching off a key    coderanch.com

Does anybody know of any way to switch off a key (specifically the NUM LOCK key), via Java? I can get it to do all sorts of things but how do I get it to not do stuff? I've asked this question a couple of times already but I'm still waiting for the answer. I hope someone can point me in ...

22. Reading keys as they are pressed, how?    coderanch.com

I need to read keys the moment they are pressed but most streams seem to wait for a "end of input" char or something. I've been told that it's possible with awt and swing, but I would rather not involve the gui stuff. So is there an easy way to do it?

23. Manipulating large file containing key value pairs    coderanch.com

Hi, I have a very large file which contains data with the below format key=value1,value2 key_value1=somedata1$somedata2 .... I cannot use database (like Oracle/Access etc.) but I could have a different file type like .xls etc. (this might change the data format, but it is ok). Can some one suggest me an efficient way to read and manipulate the file (like update, ...

24. How to make program quit if user presses ESC key?    coderanch.com

Not easily done. You can't read a single key press off of the console in Java without resorting to native code. You can add a key listener to a GUI component but you will only get key presses if the component has focus. If you make a frame a key press listener and a button on the frame has the focus ...

25. Selector returns set of keys which are already processed in loop before    coderanch.com

hi. i am facing problem as following: i have a Selector and a ServerSocketChanner with non-blocking configuration. now in main loop, i perform while(true) { int keysAdded = selector.select(); if(keysAdded == 0) { continue; } Set keysReady = selector.selectedKeys(); Iterator itrKey = keysReady.iterator(); while(itrKey.hasNext()) { selectedKey = (SelectionKey) itrKey.next(); itrKey.remove(); } } //end while Only single client is connecting to it ...

26. Press any key to continue...    coderanch.com

It may have been discussed many times, but the answer is always very simple: you can't do it. Furthermore, java.io.Console doesn't help: it only provides line-buffered-non-echoed reads for reading passwords, not any kind of general console-handling. There's a library called "JLine" out there that might do this; I'm not sure. It uses native code, as any solution would need to.

31. how would I go about reading more than one key at a time?    coderanch.com

You can't read multiple keys at a time, since you only get one key per event. What you can do is store the keys that have been pressed: private Set keys = new HashSet(); public void keyPressed(KeyEvent e) { keys.add(e.getKeyCode()); } public void keyReleased(KeyEvent e) { keys.remove(e.getKeyCode()); }Of course, if you only want to monitor a few keys (like cursor keys) ...

32. Read out of focus key press    coderanch.com

Hi, I am developing a simple application, where in, there is no UI involved. My java code will be running as a background process. I want to make the program such that, if the user presses the key anywhere i.e. on any window running on the system, my program will be triggered and it will record the key pressed. In short, ...

33. RAS+public private key encrypt +decrypt+ file size larger    coderanch.com

Dear friends, I am doing encrypting decrypting of any type files using My RSA+private key ,public key alogorithm in java. My issue is wheever i enctyprt any .tar files the size of the encrypted file is larger than the original .tar file. But encryption is ok and decryption also ok. Thanks Rakesh

34. how to serialize a java.security.key    coderanch.com

sudheer kiran wrote:hi Ulf Dittmer, i cannot change map from map..as map is used every where in my project; so i need to convert a "java.security.key' object to String Object and store into map. and i should retrieve and convert it back to Key object. is that possible. java.security.Key has a method getEncoded() which return a byte[] array representing ...

35. File decryption fails when using a key of bit size 2048    coderanch.com

Hello, File decryption fails when using a key of bit size 2048 & 4096 to encrypt/decrypt. File encryption works ok. The file size doesnt seem to matter. Im running some tests hence the large keys Also know that symmetric encryption is better for files.. See the exception thrown below: javax.crypto.BadPaddingException: Data must start with zero at sun.security.rsa.RSAPadding.unpadV15(Unknown Source) at sun.security.rsa.RSAPadding.unpad(Unknown Source) ...

36. PGP encrypting using .asc public key file - encrypt String    coderanch.com

Hi, I am trying to PGP encrypt a String object, I base 64 encode it and send it to our client. The person that is trying to decrypt it keep getting a "Secret key for message not found error. I copy pasted the code below as well as output: Any advice would be appreciated. //Java imports import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import ...

37. Err:java.io.IOException: public key ring doesn't start with public key tag    java-forums.org

public static PGPPublicKey pgpCheck() { PGPPublicKey pkey=null; StringBuffer encoded64 = new StringBuffer(); try { BufferedReader rdr = new BufferedReader(new FileReader("C:\\key.txt")); String line = rdr.readLine(); while (line != null) { encoded64.append(line); line = rdr.readLine(); } rdr.close(); System.out.println("Result string is...\n" + encoded64.toString()); [COLOR="Red"] PGPPublicKeyRing keyring = new PGPPublicKeyRing(Base64.decode(encoded64.toString().getBytes()));[/COLOR] pkey = keyring.getPublicKey(); System.out.println("Public key: id - " + pkey.getKeyID()); System.out.println(" : Alg - " ...

38. RAS+public private key encrypt +decrypt+ file size larger    forums.oracle.com

By how much is the file size increasing? Depending on how you do the actual encryption, it can easily grow a bit due to varying headers and some padding, but it shouldn't be a significant part of the file size if the file is reasonably big. If, however, the file size grows by some significant factor (say your output is 2 ...

40. RSA Reading Private Key from File    forums.oracle.com

static void FileEncryption ()throws Exception { Security.addProvider(new BouncyCastleProvider()); // Getting the path of the file to be encrypted System.out.print("Enter the filename to be encrypted\n(full path is needed if not located at the same directory): "); String FileName = null; BufferedReader brf = new BufferedReader(new InputStreamReader(System.in)); try { FileName = brf.readLine(); } catch (IOException IOE) { System.out.println("IO error trying to read your ...

41. detect if a file is opened by clicking and hitting "Enter" key ?    forums.oracle.com

I am running a cyber cafe, aka CC, and the CC server software required that the user to login as administrator in order to run the CC server software. This CC software is using MS Access. The problem is that I afraid the operator of my shop open up the MDB file and change the data inside. But this MDB also ...

43. Write - key combination to file?    forums.oracle.com

There's no such thing as a character for alt or enter. They're sometimes called meta-keys, and what an application does when they are pressed is up to the application. Usually enter creates a line break, but even then, the characters that make up a line break are platform dependent. Explain what you are trying to accomplish, and we can probably suggest ...

44. How to get random number from private key file 'PriKey.key'?    forums.oracle.com

Hi! every java developers. Is there someone who know how to get random number(RandomNum) from private key file 'PriKey.key'? I know random number(RandomNum) is used to make private key. In my B2B project, I have to attach the random number(RandomNum) used in my private key to my soap message to make identification certification. But I don't know how to do it. ...

45. Retrieving keys from config file    forums.oracle.com

- The configuration files in java are usually properties file, which are simply a list of key,value pairs. Property files does not support multiple sections. /jre/lib has several property files that are used by java itself. Please take a look at http://java.sun.com/docs/books/tutorial/essential/environment/properties.html which has code snippets on reading property files. As long as the key values are unique, you should use ...

46. retreiving a private key from a file    forums.oracle.com