Networking :: Get Timestamp Of A File On Server
Aug 6, 2014
I have a requirement to get the details of the files present in a directory on a server. I need to get the file names and timestamp. I have the below code to get the file names:
Connection conn = new OracleDriver().defaultConnection();
ArrayDescriptor arraydesc =
ArrayDescriptor.createDescriptor ("DIRLIST_T", conn);
File myDir = new File (dir);
String[] filesList = myDir.list();
ARRAY dirArray = new ARRAY(arraydesc, conn, filesList);
return dirArray;
But am not able to get the timestamp. How can I get the timestamp as well.
View Replies
ADVERTISEMENT
Jun 26, 2015
I am trying to create a new text file in FTP Server using FTPClient but im not able to do. By using storeFile method i can only upload file that is already exists in my local system. But my requirement is to create file directly into FTP Server.
View Replies
View Related
Apr 17, 2008
I'm facing some problem connecting to a IBM 4690 OS Server with the FTPClient class from the commons-net-1.4.1 library. It seems it can't read the folder on the server. The problem is that using the FTP client from Internet Explorer is works perfectly.
Here is my code (kind of hardcoded but it's only to test).
FTPFile[] files = null;
try {
files = listFiles(remoteFolder);
} catch (ParserInitializationException e) {
[Code] ...
Here is the ParserInitializationException that it throws:
org.apache.commons.net.ftp.parser.ParserInitializationException: Unknown parser type: OS 4690 operating system
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:118)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2358)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2141)
...
I've tried to use many of the FTPFileListParser available but without success. How could I handle the problem? Where could I find a Parser that would works?
View Replies
View Related
Jun 8, 2014
I read and then copy files into a subfolder, and I need to rename the file names by adding the timestamp to the file name, for example like: "filename1_25.06.14_15:00:00.txt". How can I do that? Here is what I have:
public class Table_data {
static String files = null;
static List<O> l= new ArrayList<O>();
[Code]....
is it right what i tryed, because i get nothing with timestamp in file after running this.
View Replies
View Related
Feb 5, 2015
I need to generate a file in Java with Unix TimeStamp. Want to generate an ordered list of Data entry objects for a defined period of time e.g., getData (long startTimeStamp, endTimeStamp, long resolution).
1) I would like to generate resolution with random numbers by using Random class.
2) How to take Start and end timestamps to generate a file (i.e., writing into a file).
View Replies
View Related
Dec 11, 2014
I want to pass the current timestamp as a key-value pair in JSON and want to store that timestamp in my DynamoDB table. Any sample code in JAVA to perform this operation.
View Replies
View Related
Oct 27, 2014
I am creating a java plugin for moving data from cassandra database to elastic search.
I am getting all the data but the date which I am getting from the database is in human readable form ie Row[Fri Jul 25 11:36:10 IST 2014].
I want this to be converted to epoch timestamp format like 1414386721. How to do this.
How to get the date from the row object above ie I want to get the date from Row[Fri Jul 25 11:36:10 IST 2014].
View Replies
View Related
Dec 26, 2014
I have a requirement to convert 'unix time stamp' to 'Date time format'
Input (Unix time stamp) : 1426013480000
Output should show : 3/10/2015 2:51 PM EST (or) 10th March 2015 2:51PM EST
View Replies
View Related
Mar 4, 2015
I am creating a server that stores application updates. When the client connects the server send the update. The server is sending the file but the file is not complete, i.e, if the file is 317kb,its send 117kb. Below is the code I am using :
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class TestFileServer {
[Code] ....
What could the problem be?
View Replies
View Related
May 21, 2014
I am developing a web application in java(JSF 2.0 - Prime Faces). I need to do below operation. My appllication is running on WLS server. WLS is deployed on a server(say Machine-X). In my application i have a requirement , where i have to copy file from Machine-X to another Machine-Y. The Machine-Y is access restricted.
When i tried to copy the file from my app, getting no access exception. I have full control over Machine-Y. We cannot use SFTP as SFTP cannot be installed on target machine(Machine-Y). Robocopy is failing for some use cases. Is there any other way we can copy/write file from one server to other by providing userid/password in java
View Replies
View Related
Jan 25, 2014
I want to create a simple ftp server which can upload and download a single file. i found code from google search but its showing error : connection refused . here is my server code n client code.
//server code
[highlight = java]
import java.io.*;
import java.net.*;
[Code].....
View Replies
View Related
Jun 16, 2014
I have also tried above code with few changes but I got error. Code and error show below.
Java Code:
package practice;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
[Code] .....
Error:
Java Code:
Jun 16, 2014 6:21:33 PM practice.TestFTPProgram main
SEVERE: null
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
[Code] .....
View Replies
View Related
Jan 23, 2013
I'm using EJB 3.1 and JBOSS 7.1.. Is it possible to create and write a file(CSV) directly to SFTP server?
View Replies
View Related
Sep 2, 2014
So I'm working on some networking code and I have the Server running as its own thread, then I have a PacketListener which is contained in the Server, that is running on its own thread too. As of right now, the PacketListener waits for packets via DatagramSocket.receive() and then adds them to a queue. The Server runs in a loop and it checks that queue for packets and then polls the most recent and process it before sleeping for 1 millisecond. Here is my question though, I'm considering changing the program to a more observer pattern structure in that when the PacketListener would receive a packet, rather than add it to the queue, it'd notify the server which would process it. However, wouldn't this cause additional time required within the PacketListener thread dedicated to processing the packets rather than listening for them?
View Replies
View Related
Aug 8, 2014
I'm trying to do a program that send a single file from a client to a default directory of a Server. The program use the datagramSocket and datagramPacket for the transfer via UDP. The client sent the packet of the file correctly and the server start the receiving but every time the Server class crashes after it's receiving 4/5 packet (exactly 8192 byte)
Then i put the code of the 2 class and the 2 output.
OUTPUT CLIENT:
PROGRAM TRANSFER PACKAGES
name of file is : Doc1.pdf
his dimension: 11408 byte
*** start sending
- 1024 byte
- 2048 byte
- 3072 byte
- 4096 byte
- 5120 byte
- 6144 byte
- 7168 byte
- 8192 byte
- 9216 byte
- 10240 byte
- 11264 byte
- 11408 byte
*** FILE SUCCESFULL SENDED***
BUILD SUCCESSFUL (total time: 3 seconds)
OUTPUT SERVER
PROGRAM TRANSFER PACKAGES
START NEW CONNECTION
Directory: C:prova
Server waiting in port: 9876
Waiting Client...
Name of file is : Doc1.pdf
Dimension : 11408
[Code] ....
In this point the program go in loop and didn't anything. I don't understand how can i resolve it...
SERVER
package udp_pacchetti;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
[Code] ...
View Replies
View Related
Jun 18, 2015
When a JavaScript client attempts to open a socket, instead of the connection opening it immediately closes. The client is using:
webSocket = new WebSocket("ws://localhost/example");
The same thing happens for com.sun.net.httpserver.HttpsServer where client is using:
webSocket = new WebSocket("wss://localhost/example");
How can I enable websocket support?
If it's not possible, how can I request for it to be added as a new feature?
View Replies
View Related
Mar 18, 2015
I would like to limit my bandwidth usage when accessing/downloading files (similar to the --limit-rate 50K option for curl and wget) as the website has limited bandwidth. I am not exactly sure how to implement this, but I'm guessing it be accomplished via the BufferedReader? I have attached the current code below.
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
[Code]....
View Replies
View Related
Feb 16, 2013
I have noticed an error, that makes sometimes troubles, when downloading jars from https addresses, when there are many jars to download..
Best example is by opening Javas on Java version checker. [URL] ....
I get also following log...
network: Connecting https://www.java.com/jsp_utils/jreverification.jar with proxy=DIRECT
network: Connecting http://www.java.com:443/ with proxy=DIRECT
network: Connecting https://www.java.com/jsp_utils/jreverification.jar with cookie "JSESSIONID=22ABBA2BE9B5789629C276AC35BDF969; s_cc=true;
Even if the address is https, java try to access via http protocol on port 443, and that leads sometimes to problems..
I have noticed this, when I have used URLConnection(HttpURLConnection) for my self, as soon Java sends http link on https address, the jar gets sometimes not loaded, and i get error about missing class that get called..
On http addres it is not so bad, since same protocol is used, but evidently, that is evil for https..
As you see, that happens already when loading Jar by Applet Starter and at all, it happens each time on any URLConnection
###############################
Java Plug-in 10.13.2.20
Using JRE version 1.7.0_13-b20 Java HotSpot(TM) Client VM
User home directory = X:Usersadmin
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
[Code] .....
View Replies
View Related
Nov 9, 2013
I wrote a proxy in java. The version with ServerSocket-Socket/Stream-IO works wonderfully. When I rewrote it to ServerSocketChannel-SocketChannel/ByteBuffer it works also very well. However, when I access YouTube things happen weirdly: The video is frozen after 3 or 5 minutes (but this did not with the version of ServerSocket/Socket). I strongly assume that there probably was a nasty bug.... The (shortened) codes are:
Server:
public class BeanServer extends Thread {
public BeanServer( ) { }
public void run( ) {
try {
bServer = ServerSocketChannel.open();
[Code] .....
View Replies
View Related
Jan 30, 2014
My application with Oracle Database only works with Ethernet, I tried to connect via wireless without any response. When I run the command netstat the port state is WAIT TIME and then be closing. The clients machines run Windows 7 and 8 and the server run Suse Linux Enterprise Server 10 SP2, if the client machine run XP all works fine. I disabled the firewalls in the both sides.
View Replies
View Related
Jun 24, 2014
We have a servlet application running under jboss 7.1.1/java 1.7 that sends http requests to another server. Everything works fine for most of the time, but occasionally (from one to a couple of times a day) we get a “Socket closed” exception. I’ve been trying to find out what might be causing this but so far I’ve been unsuccessful. By the way, this has been happening while the application was running under older versions of Jboss/Java so the version might not be that relevant.
Here’s an excerpt from the method where this happens:
. . . . .
try
{
HttpURLConnection conn = (HttpURLConnection) urlEndpoint.openConnection();
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
[Code] ....
And here’s what the exception looks like:
. . . . . .
java.net.SocketException: socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
[Code] ....
In my investigation I came across some posts that were mentioning the sockets pool the http connection is keeping, but I’m not sure whether and how this solve the problem I have.
View Replies
View Related
Dec 12, 2014
Similar to HttpFilter (javax.Servlet.Filter ) which when added in web.xml can intercept any incoming request to JVM / outgoing (as response) independent of framework ( Spring/CXF/Jersy etc ) without any code changes (excluding the filter itself), I am trying to find an API or approach which could intercept any outgoing HTTP calls from JVM to add/modify headers independent of framework.
Quite often the word Outgoing HTTP call is misinterpreted in the forums so let me explain with example.
Let us assume there are two JVMs, jvm1 and jvm2. and there are HTTP calls being made from JVM1 to JVM2. I would like to intercept the HTTP connection being made from JVM1 to modify the headers information before the call happens. I do not want the code to be tied to a specific framework so that I can as bundle the interceptor as a jar and share it with application team. Changes in web.xml is fine.
View Replies
View Related
Jun 30, 2014
I have a code that uploads files in server after browsing folders and files then get the paths of files but I have a problem in getting the paths
List items = upload.parseRequest(request);
Iterator iterator = items.iterator();
while (iterator.hasNext()) {
FileItem item = (FileItem) iterator.next();
if (!item.isFormField())
{ fileName = item.getName();
root = getServletContext().getRealPath("/");
path = new File(root + "/uploads");
[Code]...
list1 must has paths that I want but I do not get the paths of upload files
View Replies
View Related
Jul 27, 2014
I am developing a web application using JSF-2.0 on weblogic 10.3.6. I am using Facelets as VDL. I have 5 different machine. They are different according to their OS and their geographical location. On my first xhtml page server (machine) is decided. Then on next page file upload and rest of processing takes place. My restriction is that SSO configuration can be done on only one machine.
So I am restricted to using xhtml files from only my primary server where SSO configuration is done. But I have to connect to servlets or managed-bean of different machine as requests are machine specific and file needs to be uploaded to those machines for processing. So I cannot use redirectUrl as I need to be only on one machine. Is it possible that xhtml on one server can talk to managed-bean on other server(different machine)?.
View Replies
View Related
Oct 14, 2014
I am trying to remotely call one servlet and getting below exception:
java.io.StreamCorruptedException: invalid stream header: 3C21444F
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:785)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:282)
at com.deere.isg.dm.web.controller.StatsController.getOtherAdminStatsBeanFromConnectURL2(StatsController.java:224)
at com.deere.isg.dm.web.controller.StatsController.main(StatsController.java:122)
As per my program i am just simply calling this:
URL url = new URL(controllerPath + STATS_PATH);
httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
inputStream = httpURLConnection.getInputStream();
objectInputStream = new ObjectInputStream(inputStream);
View Replies
View Related
Oct 27, 2014
I'm trying to write a transparent proxy like polipo. Polipo is written in C and I want to have the same result in java.
A simple program that can filter/monitor all connections created and closed by the browser.
To do so, I've chosen to work with sockets, because that's the only way i know to read and write raw data to and from the browser in a completely transparent way.
In this moment my code reads and writes every couple of request/response but I've noticed profiling it that the time needed to create the socket is a bottleneck.
Using URLConnection to create the same connection I need much less time than sockets.
When socket creation implies 50ms URLConnection implies only 1ms.
View Replies
View Related