Problem in reading a russian File

Hello,
I need to Load an MySQL DB from an CSV File which is in Russian,
My CSV File is correctly made an I can open it an read the Data on a text Editor,
I can too in Sunopsis but the data are not made of good characters.
When Sunopsis send data to MySQL (which is in UTF-8) my data are unreadable...
Is there somewhere I can define the encoding of my data in Sunopsis ???
I am on Sunopsis V3.2
Thanks in advance

2 ways:
- small file : LKM file to SQL but precise UTF8 in your file description in topology (charset_encodin)
- big file: look for a LKM o build it using my sql syntax
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[FIELDS
[TERMINATED BY '\t']
[[OPTIONALLY] ENCLOSED BY '']
[ESCAPED BY '\\' ]
[LINES
        [STARTING BY '']
[TERMINATED BY '\n']
[IGNORE number LINES]
[(col_name,...)]

Similar Messages

  • Problem in reading no. of files and writing into a single file

    Hi,
    Iam with Problem in reading no. of files and writing into a single file....
    Iam reading no. of files stored in local directory.......
    Iam able to read and print the data in files successfully....but while writing..only first file is being written...and the next files are not written in my output file...
    plz tell me my mistake....I hope Iam doing some mistake while writing into file...PLz help.....
    Basically my code structure is like this....
    import java.io.*;
    import java.util.regex.*;
    import java.util.*;
    import java.text.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    class Writing {
    public static void main(String args[]) throws Exception {
              FileOutputStream fileOut = new FileOutputStream("ServerResult.xls"); //my output file
              int counter = 1;
              File dir = new File("C:/Perform/ServerLogs");
              String[] children = dir.list();
              if( children == null)
                   System.out.println("The Directory mentioned does not exist");
              else {
                   for (int fileNo = 0; fileNo < children.length; fileNo++ ) {        //Files iteration starts
                        String filename = children[fileNo];
              File logFile = new File(filename);
    FileReader logFileReader = new FileReader(logFile);
    BufferedReader logReader = new BufferedReader(logFileReader);
    StringBuffer sBuf = new StringBuffer(5000);
              HSSFWorkbook wb = new HSSFWorkbook();          
              HSSFSheet sheet = wb.createSheet();
              HSSFRow rowTitle;
              HSSFRow rowReq;
              HSSFRow rowRes;
    String aLine = null;
    boolean skip = false;
    boolean readed = false;
    boolean initReq = false;
              boolean flag = false;
    long requestTime = 0;
    long responseTime = 0;
    long recdTime = 0;
    long sentTime = 0;
              long hasTime = 0;
              long presentTime = 0;
              int hasCalls = 0;
    Pattern startMessage = Pattern.compile("^<MESSAGE.*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern requestMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<ActName>(.*)</ActName>.*", Pattern.DOTALL);
    Pattern requestMessage1 = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<Svc id=\"(.*)\">.*", Pattern.DOTALL);
    Pattern responseMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"HostConnInit\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initResMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*", Pattern.DOTALL);
    Pattern initResIDMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*<IATA>"+args[0]+"</IATA>.*", Pattern.DOTALL);
              Pattern sentMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgSentInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
              Pattern rcvdMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgRcvdInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    DecimalFormat dcf = new DecimalFormat("########.##");
    String actName = "";
              if (fileNo ==0)
              rowTitle = sheet.createRow((short)0);
              rowTitle.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)0).setCellValue("Req/Res");
              rowTitle.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)1).setCellValue("Action");
              rowTitle.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)2).setCellValue("Server Time(in ms)");
              rowTitle.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)3).setCellValue("Request Vs Response Time in Server(in ms)");
              rowTitle.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)4).setCellValue("Time Taken By HAS/HOST(in ms)");
              rowTitle.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)5).setCellValue("No. of HAS calls");
              rowTitle.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)6).setCellValue("Data Size");
              //wb.write(fileOut);
    while((aLine=logReader.readLine()) != null) {
    if(aLine.startsWith("<MESSAGE TYPE=\"EVENT\"")) {
    Matcher m = startMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    initReq = false;
    m = initMessage.matcher(aLine);
    if(m.find()) {
    initReq = true;
    } else {
    if(initReq) {
    m = initResMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    } else if(aLine.startsWith("</MESSAGE>")) {
    if(!skip) {
    sBuf.append(aLine);
    readed = true;
    } else if(!skip){
    sBuf.append(aLine);
    if(!skip && readed) {
    String tempStr = sBuf.toString();
    if(tempStr.length() > 0) {
    boolean reqMatched = false;
    Matcher m = null;
    if(initReq) {
    m = initMessage.matcher(tempStr);
    actName = "Intialization";
    } else {
    m = requestMessage.matcher(tempStr);
    String time = "";
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    } else if(!initReq){
    m = requestMessage1.matcher(tempStr);
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    if(time.length() > 0 ) {
    try{
    requestTime = sdf.parse(time).getTime();
    }catch(Exception ex){}
    System.out.println("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  //bw.write("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  String reqDataSize = dcf.format(((double)time.length()/1024.0))+"K" ;
                                  rowReq = sheet.createRow((short)counter);
                                       rowReq.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)0).setCellValue("Request");
                                       rowReq.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)1).setCellValue(actName);
                                       rowReq.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)2).setCellValue(time);
                                       rowReq.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)3).setCellValue("");
                                       rowReq.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)4).setCellValue("");
                                       rowReq.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)5).setCellValue("");
                                       rowReq.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)6).setCellValue(reqDataSize);
                                       counter = counter +1;
                                       System.out.println("counter is "+counter);
                             Matcher l = sentMessage.matcher(tempStr);
                             Matcher k = rcvdMessage.matcher(tempStr);
                   if(l.find()) {
                                            for (int i=1; i<=l.groupCount(); i++) {
         String groupStr2 = l.group(i);
    try{
    sentTime = sdf.parse(groupStr2).getTime();
    }catch(Exception ex){}
                        if(k.find())
                                                 for(int j=1;j<=k.groupCount(); j++) {
                                                 String groupStr1 = k.group(j);
                                                 try{
    recdTime = sdf.parse(groupStr1).getTime();
    }catch(Exception ex){}
                                                 presentTime = (recdTime - sentTime);
                                                 hasTime = hasTime + presentTime;
                                                 hasCalls = hasCalls +1;
    if(!reqMatched) {
    if(initReq) {
    m=initResIDMessage.matcher(tempStr);
    } else {
    m=responseMessage.matcher(tempStr);
    if(m.find()) {
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    try{
    responseTime = sdf.parse(groupStr).getTime();
    }catch(Exception ex){}
                                                 String resDataSize = dcf.format(((double)tempStr.length()/1024.0))+"K" ;
                                                 rowRes = sheet.createRow((short)(counter));
                                                 rowRes.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)0).setCellValue("Response");
                                                 rowRes.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)1).setCellValue(actName);
                                                 rowRes.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)2).setCellValue(groupStr);
                                                 rowRes.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)3).setCellValue((responseTime - requestTime));
                                                 rowRes.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)4).setCellValue(hasTime);
                                                 rowRes.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)5).setCellValue(hasCalls);
                                                 rowRes.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)6).setCellValue(resDataSize);
                                                 hasTime = 0;
                                                 hasCalls = 0;
                                                 counter = counter + 1 ;
    sBuf.setLength(0);
    readed = false;
              wb.write(fileOut);
              } // End of for (int fileNo = 0; fileNo < children.length; fileNo++ )
    }     //End of else
              fileOut.close();
    } //End of public static void main
    } // End of Class

    First of all, use [code]-tags to make your code readable, please.
    I didn't do a complete inspection of your code (because it's too much and unreadable as it is) and I don't know POI, but creating a new HSSFWorkbook for each input file sounds fishy to me ... try re-using the workbook and just creating a new sheet in each iteration.

  • Problem in reading an Image file from a Output Stream.

    I am having problem reading a JPEG file. Actually i am sending JPEG file using UDP from the client. I am using this code to convert to a byte array to transmit the file:
    DataInputStream inStream = new DataInputStream(new FileInputStream("src/Bgamex.jpg"));
    String str1 = inStream.toString();
    byte[] bindata = new byte[65500];
    bindata = str1.getBytes();
    On the server side, I am using these lines to convert the bytes to a file again but it seems to be that its not working. Its making file but with a bigger size & like garbage in it, showing nothing:
    byte[] buf = new byte[65500];
    // receive request
    DatagramPacket packet = new DatagramPacket(buf, buf.length);
    socket.receive(packet);
    buf = packet.getData();
    java.io.OutputStream fos = new java.io.FileOutputStream("Bga.jpg");
    fos.write(buf);
    Could somebody lemme know the problem in converting the file.
    Thanx.

    I propose you to perform this simple test to see by yourself:     final String BIN_FILENAME = "somebytes.bin";
        byte[] bin = {5, 4, 3, 2, 1};
        FileOutputStream out = new FileOutputStream(BIN_FILENAME);
        out.write(bin);
        out.flush();
        out.close();
        byte[] bindata;
        DataInputStream in1 = new DataInputStream(new FileInputStream(BIN_FILENAME));
        String str = in1.toString();
        in1.close();
        bindata = str.getBytes();   
        System.out.print("Bytes read with in1>");
        for (int i=0; i<bindata.length; i++) System.out.print(bindata);
    System.out.println();
    FileInputStream in2 = new FileInputStream(BIN_FILENAME);
    bindata = new byte[65505];
    int bread = in2.read(bindata, 0, in2.available());
    in2.close();
    System.out.print("Bytes read with in2>");
    for (int i=0; i<bread; i++) System.out.print(bindata[i]);
    System.out.println();

  • Problem in reading a resource file form JAR

    Problem in finding a resource file from the jar.....
    I have my code in the following directory structure
    rootDir -
         libDir -
              XMLEntities.res
         modelDir -
              File1
              File2
              File3
    Step1 - I create a jar file with root as modelDir and with all its files.
    Step2 - I add XMLEntities.res also to the root of the jar
    If I run my application using
    java -classpath ;C:\aip_build\build_dm\rmi_server_files\dm.jar; model.data_model.ActivateDataManager
    My application which uses Xalan.jar (lyong under ext directory in jdk) does not find XMLEntiries.res.
    If I use my application as under without creating jar my application does find XMLEntites.res
    Can anyone tell me why the application can not find the XMLEntities.res inside jar?

    Sorry I missed one line............
    Problem in finding a resource file from the jar.....
    I have my code in the following directory structure
    rootDir -
    ----libDir -
    --------XMLEntities.res
    ----modelDir -
    --------File1
    --------File2
    --------File3
    Step1 - I create a jar file with root as modelDir and
    with all its files.
    Step2 - I add XMLEntities.res also to the root of the
    jar
    If I run my application using
    java -classpath
    ;C:\aip_build\build_dm\rmi_server_files\dm.jar;
    model.data_model.ActivateDataManager
    My application which uses Xalan.jar (lyong under ext
    directory in jdk) does not find XMLEntiries.res.
    If I use my application as under without creating jar
    my application does find XMLEntites.res
    java -classpath
    ;C:\aip_build\build_dm\rmi_server_files\;C:\aip_build\b
    ild_dm\rmi_server_files\lib
    model.data_model.ActivateDataManager
    Can anyone tell me why the application can not find
    the XMLEntities.res inside jar?try loading the resources as a InputStream
    something like :
    InputStream is = NameOfLoadingClass.class.getClassLoader().getResourceAsStream("XMLEntities.res");
    Hope this might help you in some way.

  • Help! Problem with reading objects from file

    I wrote a "Library" program for an assignment, and one of the requirements is that the library store all of its information to file upon exit, and reload this information from file when run.
    Well, the writing to file part is working. I'm using a FileOutputStream object and an ObjectOutputStream object. I can tell from the file size of the .dat file that information is going into it.
    But what I can't do is read from file. For that, I'm using a FileInputStream and an ObjectInputStream. I keep getting this exception:
    java.io.EOFException
         at java.io.DataInputStream.readInt(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readInt(Unknown Source)
         at java.io.ObjectInputStream.readInt(Unknown Source)
         at Library.readDataFromFile(Library.java:350)
         at Library.<init>(Library.java:63)
         at LibraryDriver.main(LibraryDriver.java:6)I looked this exception up and it says it's thrown when a data input stream unexpectedly ends....But I am instantiating the input streams just before I try to read from file:
                            fileInStream = new FileInputStream(libraryFile);
                   objInStream = new ObjectInputStream(fileInStream);
                   Object[] objectArray = new Object[objInStream.readInt()];Both input streams have methods that "return the number of bytes that can be read from this file input stream without blocking". Just for kicks, I tried writing that number to the console.
    For the FileInputStream, I get 404 bytes.
    For the ObjectInputStream, I get 0 bytes.
    So I guess it's a problem with the ObjectInputStream? Anyone have any suggestions as to how I can fix this, please?

    Yep, here's the relevant code from the writeToFile() method:
                          for (int i = 0; i < libraryAuthors.length; i++) {
                        currentAlphaAuthorList = libraryAuthors;
                        for (int j = 0; j < currentAlphaAuthorList.size(); j++) {
                             currentAuthor = (Author) currentAlphaAuthorList.get(j);
                             objOutStream.writeObject(currentAuthor);
                   objOutStream.flush();
                   objOutStream.close();

  • Problem in Reading a .PDF file

    HI Friends,
    I am reading a .pdf file from within java program using its java.io package.
    I am able to read the file, but when I print the line read from file on to the screen, it all garbage. Its not in readable characters.
    I guess its reagrding mismatch in Charcter Sets of original file and the stream with which I m reading the file.
    So,if u know the solution plz suggest me.

    Hello Simple@java
    Here's an exemple of a class that opens the File "rapport.pdf" located at the same place as the class.
    Of course AcroRd32.exe is the name of Acrobat Reader which allows to read pdf files. You can get it on : adobe.com(http://www.adobe.com/products/acrobat/readstep2.html)
    You will change "rapport.pdf" by the name of your pdf file.
    Then execute "test()".
    * Open the file "rapport.pdf"
    public class test
         public test()
              Runtime a = Runtime.getRuntime();
              try
                   a.exec("AcroRd32.exe rapport.pdf");               
              catch (Exception e)
                   System.out.println(e.getMessage());
    Good luck !

  • Problem in reading the excel file path in WINDOWs machine from UNIX environ

    Hello friends,
    My requirement is to read each row of the excel sheet and sent that row to the database. I have implemented it by using jxl and apache poi framework. locally in my WINDOWS machine it is working fine..
    But when i deploy the code in UNIX machine. My application runs on a Unix server , trying to read the excel file in WINDOWS environment. I am not able to retrieve the file path. for ex : C:\Documents and Settings\sabbanik\My Documents\KARUNAKAR\excel.xls
    I am getting error in this line
    workbook = Workbook.getWorkbook(filepath)
    Error message : input file not found.
    Thanks in advance..

    You said: I am getting error in this line workbook = Workbook.getWorkbook(filepath) >
    Based on this, I will assume you are trying to use OLE to access information about the Excel file. As mentioned by Andreas, your code will be executing on the server (Unix) and since Excel isn't on the server (and cannot be) an error will result. OLE can only be used in Windows environments (client or server). To access client side OLE calls and content, you need a java bean and Excel installed on the client machine. Oracle provides WebUtil as an option to writing your own Java Bean. To use this, you will need to be running Forms 10.1.2 or newer. Details can be found here along with a demo:
    http://www.oracle.com/technetwork/developer-tools/forms/webutil-090641.htm

  • Problem with reading from a file

    `HI,
    i am trying to read from a text file... using following piece of code
    try{               
                   BufferedReader in = new BufferedReader( new FileReader(fileName), 100000);
                   while (in.readLine() != null)
                        temp = in.readLine();
                   in.close();
                   in = null;
                   } catch(Exception e) {System.err.println(e); }          
                   System.out.println(temp);     
    text contains almost 7500 words...
    but when i run this piece of code... output i got is NULL
    ... i don't know what i am doing wrong...
    any suggestions
    <Thanx in advance >

    while (in.readLine() != null)Right here, you are reading in the file, but you don't store the content.
    temp = in.readLine();By the time you reach here, you have already read in the whole file, so there is nothing left to read. That's why temp is assigned null

  • Problem with reading from bin file into Vector

    What am I doing wrong? It works fine to write the vector to the bin file and then read from it. But if I try just to read from the file it wont work.
    Does anybody has any good advice to give when it comes to reading data form a bin file??
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    class Binaerfil
         public static void main (String [] args) throws IOException, ClassNotFoundException{
              ObjectOutputStream utFil = new ObjectOutputStream (new FileOutputStream("HighScoreLista.bin"));
              int po = 50;
              Spelare s;
              Spelare s1, s2, s3, s4, s5,s6,s7,s8,s9,s10;
              String f�rNamn;
              Vector v = new Vector();
              s1 = new Spelare("Mario", 100);
              s2 = new Spelare("Tobias",90 );
              s3 = new Spelare("Sanja", 80 );
              s4 = new Spelare("Marko", 70 );
              s5 = new Spelare("Sofia", 60 );
              s6 = new Spelare("Kalle", 50 );
              s7 = new Spelare("Lisa", 40 );
              s8 = new Spelare("Pelle", 30 );
              s9 = new Spelare("Olle", 20 );
              s10 = new Spelare("Maria",10 );
              v.add(s1);
              v.add(s2);
              v.add(s3);
              v.add(s4);
              v.add(s5);
              v.add(s6);
              v.add(s7);
              v.add(s8);
              v.add(s9);
              v.add(s10);
              System.out.println ("Before writing to file");
              System.out.println(v);
              //Write to file
              utFil.writeObject (v);
              utFil.close();
         ObjectInputStream inFil = new ObjectInputStream (new FileInputStream("HighScoreLista.bin"));     
              v =(Vector) inFil.readObject();
         System.out.println (v);
              inFil.close();
    }

    Because what you are writing to the file is a vector, that is all you can get out. You are actually reading a single Object from the file which you can cast to a Vector, from which you can access the data stored inside. If you want to read the Spelare instances from the file, you will have to save them individually to the file. You will have to implement Serializable and look up the API to do that.

  • Problem with reading from DAT file. FileNotFound exception

    Can't seem to find the issue here. Two files, one (listOfHockeyPlayers) reads from a DAT file a list of players. The other (HockeyPlayer) has just the constructor to make a new hockey player from the read data.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.awt.*;
    import java.io.*;
    public class ImportHockeyPlayers
    private ArrayList<HockeyPlayer> listOfHockeyPlayers = new ArrayList<HockeyPlayer>();
    public ImportHockeyPlayers(String fileName)
      throws FileNotFoundException
      try
       Scanner scan = new Scanner(new File(fileName));
       while (scan.hasNext())
        //Uses all the parameters from the HockeyPlayer constructor
        String firstName = scan.next();
        String lastName = scan.next();
        int num = scan.nextInt();
        String country = scan.next();
        int dob = scan.nextInt();
        String hand = scan.next();
        int playerGoals = scan.nextInt();
        int playerAssists = scan.nextInt();
        int playerPoints = playerGoals + playerAssists;
        //listOfHockeyPlayers.add(new HockeyPlayer(scan.next(),scan.next(),scan.nextInt(),scan.next(),scan.nextInt(),scan.next(),
         //scan.nextInt(),scan.nextInt(),scan.nextInt()));
      catch(FileNotFoundException e)
       throw new FileNotFoundException("File Not Found!");
    public String toString()
      String s = "";
      for(int i = 0; i < listOfHockeyPlayers.size(); i++)
       s += listOfHockeyPlayers.get(i);
      return s;
    public class HockeyPlayer
    private String playerFirstName;
    private String playerLastName;
    private int playerNum;
    private String playerCountry;
    private int playerDOB;
    private String playerHanded;
    private int playerGoals;
    private int playerAssists;
    private int playerPoints;
    public HockeyPlayer(String firstName, String lastName, int num, String country, int DOB,
      String hand, int goals, int assists, int points)
      this.playerFirstName = firstName;
      this.playerLastName = lastName;
      this.playerNum = num;
      this.playerCountry = country;
      this.playerDOB = DOB;
      this.playerHanded = hand;
      this.playerGoals = goals;
      this.playerAssists = assists;
      this.playerPoints = goals + assists;
    DAT File
    Wayne Gretzky 99 CAN 8/13/87 R 120 222
    Joe Sakic 19 CAN 9/30/77 L 123 210These are all in early development, we seem to have the idea down but keep getting the odd FileNotFound exception when making an object of the ImportHockeyPlayers class with the parameter of the DAT file.
    We might even be on the wrong track with an easier way to do this. To give you an idea of what we want to do...read from the file and be able to pretty much plug in al lthe players into a GUI with a list of the all the players.
    Thanks for your time.

    Thanks for the tip on the date format...good to
    know.
    public static void main(String[] args)
    GUI gui = new GUI();
    ImportHockeyPlayers ihp = new
    ImportHockeyPlayers("HockeyPlayers.dat");
    }It's just being called in the main.
    Throws this error:
    GUI.java:39: unreported exception
    java.io.FileNotFoundException; must be caught or
    declared to be thrown
    ImportHockeyPlayers ihp = new
    ImportHockeyPlayers("HockeyPlayers.dat");
    ^This error is simply telling you that an exception may occur so you must enclose it in a try catch block or change the main method to throw the exception as follows
    public static void main(String[] args) throws  
                          java.io.FileNotFoundException {
         GUI gui = new GUI();
         ImportHockeyPlayers ihp = new
         ImportHockeyPlayers("HockeyPlayers.dat");
    }or
    public static void main(String[] args) {
         GUI gui = new GUI();
         try {
              ImportHockeyPlayers ihp = new
              ImportHockeyPlayers("HockeyPlayers.dat");
         catch (FileNotFoundException e) {
              System.out.println("error, file not found");
    }I would reccomend the second approch, it will be more helpful in debugging, also make sure that the capitalization of "HockeyPlayers.dat" is correct
    hope that helps

  • Problem in reading from the File

    Hi,
    I have a dataset.txt file which is as follows:
    2
    4
    1 2 3 4
    2 3 4 5
    3 4 5 6now that I need the value that is present in the 1st line of the file(ie;2) and value present in the 2nd line of the file(ie;4), upon that i'll be reading the data into an array.
    for this task of mine to accomplish , i'm using the following code
    String line_1;
    String line_2;
              int first_line,second_line;
              DataInputStream dis1 =null;
              DataInputStream dis2 =null;
              System.out.println("Print this");
              try
                   File f1=null;
                   f1 = new File ("dataset.txt");
                   File f2=null;
                  f2 = new File ("dataset.txt");
                 FileInputStream fis1 = new FileInputStream(f1);
                 FileInputStream fis2 = new FileInputStream(f2);
                 dis1 = new DataInputStream(fis1);
                 dis2 = new DataInputStream(fis2);
                           BufferedReader line1 = new BufferedReader(new InputStreamReader(dis1));
                      line_1=line1.readLine();
                      first_line=Integer.parseInt(line_1);
                      System.out.println("Value of First_line is:     "+first_line);
                      BufferedReader line2 = new BufferedReader(new InputStreamReader(dis2));
                      line_2=line2.readLine();
                      second_line=Integer.parseInt(line_2);
                      System.out.println("Value of Second_line is:     "+second_line);
    }//end of try
    catch(Exception e)
    {e.printStackTrace();}The problem here I'm having is, when i'm printing I'm getting the follow result
    Value of First_line is:2
    Value of Second_line is:2Instead of printing the value of Second_line as 4, it is printing 2.
    Why is this happening?
    Any kind of response is appreciated.
    Thanks is advance

    You dont have to make 2 data stream objects of the file.
    To read two lines you can just do with it object
    BufferedReader line1 = new BufferedReader(new InputStreamReader(dis1));and just call readLine( ) method twice
    line_1=line1.readLine();
    line_2=line1.readLine();

  • Problem in reading .MSG(outlook) file.

    Hello friends,
    Presently i am developing search engine which searched through mail also....
    With java api I can read .EML(outlook express ) file and get the subject, content and attachments. But when i try to read .MSG file then it gives null in subject , content and attachments.........
    So please help me solve this problem.... Is there any api is available to read .MSG file.....
    Thnx in advance.....

    First: this isn't a javamail issue.
    Second:
    Currently there is no built-in/free api available to directly read the Outlook .MSG file format. There is one from a company called priasoft that will allow you to do this. I'm working on a library that extends the POI framework (anyone know if this is still an active project?) that will allow reading/writing Outlook .MSG files.
    If you use POI you can get document node **thinks** __substg1.0_0_1000010E and it will contain the body of the document.
    I'm hoping in the next month or two I'll get enough time to create the library to do this.
    Let me know if you need any assistance.
    Thanks,
    travis (at) overwrittenstack.com (replace the (at) with @ to email me)

  • Problem to read and write files on hdd out of html with an Applet ????

    hi there,
    i wrote an applet for loading a file from HDD or saving data out of a cookie in a file on a hdd.
    when i compile the class there are warnings about "unchecked method invocation" and "unchecked conversion".
    what did i do wrong?
    i think it's about this function:
    AccessController.doPrivileged(new PrivilegedAction()
    public Object run()
    if(saveCartAtOnce.toLowerCase().compareTo("true")== 0)
    SaveShoppingCart();
    }//if
    return null;
    }// public Object run
    });//AccessController
    could anyone help me?
    i could also send the whole class then....
    thanks a lot.
    greetings
    Volker Becht
    [email protected]

    OK
    now i will post the whole class.
    my questen is: what have i to do so that anything runs?
    if anyone will need a file example which should be read
    into the calss i will email it.
    package de.CATALOGcreator.shoppingcart;
    import java.awt.*;
    import java.io.*;
    import java.applet.*;
    import java.util.*;
    import java.security.*;
    import netscape.javascript.*;
    public class shoppingcart extends java.applet.Applet
         private static final long serialVersionUID = 1234567890L;
       //Explanation of the possible Parameters of the applet, all of the following
        //parameters need not be given explicitely, because they have default values.
        String errorMessageInvalidFileFormat = "";  //set the ErrorMessage String for InvalidFileFormat when loading
        String openDialogTitle = "";                //set the Open Dialog Title
        String saveDialogTitle = "";                //set the Save Dialog Title
        String articleNumberString = "";            //set the ArticleNumber of the CSV headline
        String articleNameString = "";              //set the ArticleName of the CSV headline
        String amountString = "";                   //set the AmountName of the CSV headline
        String priceString = "";                    //set the PriceName of the CSV headline
        String delimiterString ="";                 //set the Delimiter for the Output-csv
        String inputdelimiterString ="";            //set the Delimiter for the Intput-csv
        //No parameter, this String is built from articleNumberString, articleNameString, amountString and
        //priceString and delimiterString in the following manner:
        //headline = articleNumberString + delimiterString + articleNameString + delimiterString + amountString+ delimiterString  + priceString;
        //see: init();
        String headline = "";                       //set the Headline of the csv-file
        //Another parameter is saveCartAtOnce, which says, if the save-Dialog is schown
        //at once when the applet is initialized. If the value is "true", the dialog shows
        //at once, in all other cases (also if parameter does not exist) you have to
        //call SaveShoppingCart explicitely.
        String saveCartAtOnce;
       public void init()
            try
                   //set the default setting for the Paramters
                   openDialogTitle = this.getParam("openDialogTitle", "Open Shopping Cart");
                   saveDialogTitle = this.getParam("saveDialogTitle", "Save File As");
                   errorMessageInvalidFileFormat = this.getParam("errorMessageInvalidFileFormat", "Invalid File Format!\nLoading stopped.");
                   delimiterString = this.getParam("delimiterString", "||");
                   inputdelimiterString= this.getParam("inputdelimiterString", ",");
                   articleNumberString = this.getParam("articleNumberString", "Article Number");
                   articleNameString = this.getParam("articleNameString", "Article");
                   amountString = this.getParam("amountString", "Amount");
                   priceString = this.getParam("priceString", "Price");
                   headline = articleNumberString + delimiterString + articleNameString + delimiterString + amountString + delimiterString  + priceString;
                   saveCartAtOnce = this.getParameter("saveCartAtOnce");
                   AccessController.doPrivileged(new PrivilegedAction()
                                  public Object run()
                                       if(saveCartAtOnce.toLowerCase().compareTo("true")== 0)
                                            SaveShoppingCart();
                                            //LoadShoppingCart();
                                       }//if
                                       return null;
                                  }// public Object run
                   });//AccessController
              catch(Exception e)
                   e.printStackTrace();
        }//void init
        public void  SaveShoppingCart()
            DataOutputStream dos;
            String myFile;
            File f ;
             myFile =  SaveDialog();
               if(myFile!=null)
                    f = new File(myFile);
                   String Artikel=getParameter("Artikel");
                   String Anzahl=getParameter("MyAnzahl");
                   String Bezeichnung=getParameter("Bezeichnung");
                   String Preis=getParameter("Preis");
                   StringTokenizer stArticle = new StringTokenizer(Artikel, inputdelimiterString);
                   StringTokenizer stAnzahl = new StringTokenizer(Anzahl, inputdelimiterString);
                   StringTokenizer stBezeichnung = new StringTokenizer(Bezeichnung, inputdelimiterString);
                   StringTokenizer stPreis = new StringTokenizer(Preis, inputdelimiterString);
                   JSObject.getWindow(this).eval("alert('"+ Artikel +"')");
                     try
                          dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
                          // Line 1
                        dos.writeChars(headline + "\n");
                          while (stArticle.hasMoreTokens())
                              String tmpArticle=stArticle.nextToken();
                              String tmpAnzahl=stAnzahl.nextToken();
                              String tmpBezeichnung=stBezeichnung.nextToken();
                              String tmpPreis=stPreis.nextToken();
                              dos.writeChars(tmpArticle + delimiterString + tmpBezeichnung + delimiterString +tmpPreis +  delimiterString + tmpAnzahl + "\n");
                        }//while
                          dos.flush();
                          System.out.println("Successfully wrote to the file named " + myFile + " -- go take a look at it!");
                          dos.close();
                   }//try
                      catch (SecurityException e)
                        System.out.println("JavaSoft SaveShoppingCart: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
                        e.printStackTrace(System.out);
                   }//catch
                   catch (IOException ioe)
                        System.out.println("JavaSoft SaveShoppingCart: IOexception\nMessage:" + ioe.getMessage() + "\nStackTrace:");
                        ioe.printStackTrace(System.out);
                   }//catch
              }//if
        }//void  SaveShoppingCart
        private String SaveDialog()
            try
               //Date now = new Date(System.currentTimeMillis());
                Calendar rightNow = Calendar.getInstance();
               //SystemDate
                //String strDay = Integer.toString(now.getDate());
                String strDay = Integer.toString(rightNow.get(Calendar.DAY_OF_MONTH));
                //String strMonth = Integer.toString(now.getMonth()+1);
                String strMonth = Integer.toString(rightNow.get(Calendar.MONTH));
                //String strYear = Integer.toString(now.getYear()+1900);
                String strYear = Integer.toString(rightNow.get(Calendar.YEAR));
                //SystemTime
                //String strHoure = Integer.toString(now.getHours());
                String strHoure = Integer.toString(rightNow.get(Calendar.HOUR));
                //String strMinutes = Integer.toString(now.getMinutes());
                String strMinutes = Integer.toString(rightNow.get(Calendar.MINUTE));
                //String strSeconds = Integer.toString(now.getSeconds());
                String strSeconds = Integer.toString(rightNow.get(Calendar.SECOND));
                //set SystemDate+SystemTime
                String strDate=strDay+"_"+strMonth+"_"+strYear+"_"+strHoure+"_"+strMinutes+"_"+strSeconds;
                //set SaveName as *.csv
                String SaveAs = strDate + ".csv";
                FileDialog fd = new FileDialog (new Frame(), "Save File As", FileDialog.SAVE);
                fd.setFile(SaveAs);
                fd.setVisible(true);
                //Value Save or Cancel Button
                if((fd.getDirectory() == null) || (fd.getFile() == null)) // user pressed the cancel - button
                    return null;
                }//if
                else // user pressed save - button
                    return fd.getDirectory() + fd.getFile();
                }//else
            }//try
            catch (SecurityException e)
                   System.out.println("JavaSoft String SaveDialog: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
                   e.printStackTrace(System.out);
                  return null;
            }//catch
        }// String SaveDialog
        public String OpenDialog()
               FileDialog fd = new FileDialog (new Frame(), openDialogTitle, FileDialog.LOAD);
               fd.setVisible(true);
               return fd.getDirectory() + fd.getFile();
        }//String OpenDialog
        private String getParam( String paramName, String defaultValue )
              String value = getParameter( paramName );
              if ( value != null )
                   return value;
              }//if
              return defaultValue;
        }//String getParam
        public void LoadShoppingCart()
            String myFile;
            File f ;
            myFile =  OpenDialog();
            if(myFile!=null)
                   f = new File(myFile);
                   String rl = "";
                   Object[] Obj = new Object[2];
                   try
                        DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(myFile),128));
                        // Line 1
                        String FirstLine = myReadLine(dis);
                        JSObject.getWindow(this).eval("alert('"+ FirstLine +"')");
                        if(FirstLine.startsWith(headline))
                             while ( (rl = myReadLine(dis)) != null)
                                  //examines correct delimiter
                                  StringTokenizer token = new StringTokenizer (rl, delimiterString);
                                  if(token.countTokens()!= 4)
                                       dis.close();
                                       JSObject.getWindow(this).eval("alert('"+ errorMessageInvalidFileFormat +"')");
                                  }//if
                                Obj[0]= (Object)rl;
                                Obj[1]= (Object)delimiterString;
                                JSObject.getWindow(this).call("addCSVArticle",Obj); // this=applet
                             }//while
                             JSObject.getWindow(this).call("importFinished",null);
                        else
                             dis.close();
                             JSObject.getWindow(this).eval("alert('"+ errorMessageInvalidFileFormat +"')");
                             //System.exit(-1);
                        }//else
                        dis.close();
                   }//try
                      catch (SecurityException e)
                        System.out.println("JavaSoft LoadShoppingCart: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
                        e.printStackTrace(System.out);
                   }//catch
                   catch (IOException ioe)
                        System.out.println("JavaSoft LoadShoppingCart: IOexception\nMessage:" + ioe.getMessage() + "\nStackTrace:");
                        ioe.printStackTrace(System.out);
                   }//catch
                   catch(Exception exc)
                        System.out.println("JavaSoft LoadShoppingCart: Exception\nMessage:" + exc.getMessage() + "\nStackTrace:");
                        exc.printStackTrace(System.out);
                   }//catch
              }//if
        }//void LoadShoppingCart
        private String myReadLine(DataInputStream dis)
            char tmp;
            String line = "";
            try
                while((tmp = dis.readChar())!= '\n')
                    line += tmp;
                return line;
            }//try
            catch(IOException ioexc)
                return null;
            }//catch
        }//String myReadLine
        public boolean isInitialized()
              return true;
    }//public class ShoppingCart extends java.applet.Applet[/i]

  • Problem in reading from excel file with my requirement

    Hi,
    Below is my input excel file format
    A    XXX
    B    XXX
    C    XXX
    D    E   F   G  H  I    J  K  L  M  N
    XX   XX  XX  XX.........................XX
    All the A...N are headings and XX's are values.
    How should I define an internal table for this requirement. I am using FM TEXT_CONVERT_XLS_TO_SAP to read input file.
    Please let me know the correct way to define internal table for the above file format.
    Regards,
    Cheritha

    Hello Cheritha,
    Your final internal table(t_final) should have all the fields viz. A, B, C, D etc.
    You need to read the file to an internal table say t_data. In the internal table t_data, the field values will be each row in this internal table.
    So you need to loop on t_data and based on the field name assign it to the corresponding field in the internal table t_final.
    Hope this is clear if any clarification please do reply
    Regards
    Farzan

  • Problem to read an external file in a web application

    Hello everybody.
    I'd like to know a method for reading a file (how I may connect to it?) This file is in a directory is in an external computer. I don't want to use a client/server application. I think that I must to use JNDI but I'm not sure. I think so becouse when I connect my application to external LDAP server, I use JNDI.
    I'm using Tomcat.
    Thanks a lot.
    Sorry for my English.
    I hope in your solution.
    Alessandro from Italy

    A quick Google found this:
    try
    Runtime rt = Runtime.getRuntime() ;
    Process p = rt.exec("Program.exe") ;
    InputStream in = p.getInputStream() ;
    OutputStream out = p.getOutputStream ();
    InputSream err = p,getErrorStram() ;
    //do whatever you want
    //some more code
    p.destroy() ;
    }catch(Exception exc){/*handle exception*/}Then of course you should realize that the path to the exe file must be in relation to the server.

Maybe you are looking for

  • Shuffled podcasts played one at a time

    I created a smart playlist with Podcast equals true. When I play it in shuffle mode, it plays just one podcast at a time. It simply stops after each track. If I play the playlist without shuffle, it correctly goes from podcast to podcast. This is jus

  • Unable to map a network drive in Windows 8.1 Professional

    I am using a Dell Venue 11 Pro tablet with Windows 8.1 professional. I was able to setup the domain on the tablet but I am unable to map any drives. The tablet is shown in Active Directory on our domain controller and I am using an established user n

  • Error handling in Oracle

    Hello, Could anyone help to convert the following T-SQL statement to PL-SQL? Thanks inadvance! BEGIN TRAN UPDATE Table1 SET ....... SELECT @ReturnCode = @@error IF @ReturnCode <> 0      BEGIN                     SELECT @msg = 'Error - update date fee

  • 32-bit EFI problem HELP !!!

    Hello. When snow leopard was coming out ,we were promised 64-bit ability. We rejoiced, but then later found out that the "efi" was still 32 bit. Many of us complained about false advertising etc , but then we were comforted by people that told us not

  • Java System Tray Menu

    Hi, I am able to use a png icon in my system tray element. ( TrayIcon trayIcon =new TrayIcon(createImage("/images/e-vision3.png", "tray icon"));) . Now i need to add icons to some MenuItems. ie, Both menu name and an icon. I had tried a lot to make t