Results 1 to 1 of 1
Thread: Copying Integer to a file
- 03-12-2012, 06:43 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 1
- Rep Power
- 0
Copying Integer to a file
package script;
import java.io.*;
import java.util.Calendar;
import java.io.*;
import java.text.SimpleDateFormat;
import java.io.RandomAccessFile;
import java.io.IOException;
public class DateUtils { //This function will give the current date time in our required format
public static final String DATE_FORMAT_NOW = "ddMMyyyy";
public static String now() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return sdf.format(cal.getTime());
}
public static void main(String arg[]) {
try{
RandomAccessFile br = new RandomAccessFile("/C:/SMMC/Sources/charge_SMMC_"+ DateUtils.now() +".dat", "rw");//It will create a file at desired location where all files will be merged
RandomAccessFile out = new RandomAccessFile("/C:/SMMC/Destination/charge_SMMC_"+ DateUtils.now() +".dat", "rw");//It will create a file at desired location where all files will be merged
int c,d,e,f,t=0,count=2,r=0;
while ((c = br.read()) != -1){
br.seek(t);
c = br.read();
d = br.read();
e = br.read();
f = br.read();
t++;
br.seek(t);
char c1 = (char)c;
char d1 = (char)d;
char e1 = (char)e;
char f1 = (char)f;
char[] chars = {c1,d1,e1,f1};
String covertedChars = new String(chars);
if (covertedChars.equals("BTS|")){
out.write(c);
out.write(d);
out.write(e);
out.write(f);
//char ch = (char)count;
//out.write(ch);
//out.write("|".getBytes());
t=t+3;
br.seek(t);
f=br.read();
char f2 = (char)f;
while(f2!='|')
{
if(r==0) {
// out.write(count);

r++;
}
t++;
br.seek(t);
f=br.read();
f2 = (char)f;
}
out.write(f);
while ((f = br.read()) != -1) {
out.seek(out.length());
out.write(f);
}
}
}
br.close();
out.close();
} catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
}
----------------------------------------------------------------------------------------------------
My problem is I am unable to write integer to file(BEFORE SMILEY), it is using as unicode, Can someone help me with the problem.
Thanks in advance!!
Similar Threads
-
copying file from one folder to another maintaining the file structure in java
By rahggupt in forum New To JavaReplies: 0Last Post: 11-12-2011, 01:26 PM -
Copying an mp3 from url to local file within swingworker
By peteosmith in forum AWT / SwingReplies: 9Last Post: 08-16-2011, 04:41 PM -
add to a zip file without copying it.
By yurabita in forum New To JavaReplies: 5Last Post: 08-21-2010, 03:16 AM -
Copying a file (.docx) from computers
By chyrl in forum NetworkingReplies: 3Last Post: 07-02-2010, 02:02 PM -
problems copying a file
By atom86 in forum Advanced JavaReplies: 16Last Post: 10-01-2009, 02:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks